From 28093378c8ea8faee4e6e86d86f4dc28586b82a8 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 22 Jul 2024 17:27:30 -0400 Subject: [PATCH] fix NonlinearSolverSelector MPI_COMM We forgot to initialize the mpi communicator inside this class, which is then passed to SUNDIALS and causes random crashes. Fixes #17326. --- include/deal.II/numerics/nonlinear.h | 10 ++++++++-- tests/numerics/nonlinear_solver_selector_01.cc | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/deal.II/numerics/nonlinear.h b/include/deal.II/numerics/nonlinear.h index 9ec2dfd10c..bde8ee41b6 100644 --- a/include/deal.II/numerics/nonlinear.h +++ b/include/deal.II/numerics/nonlinear.h @@ -207,9 +207,12 @@ public: NonlinearSolverSelector(); /** - * Constructor, selecting the solver and other parametersspecified in + * Constructor, selecting the solver and other parameters specified in * @p additional_data. + * + * @deprecated Use the other constructor with MPI_Comm instead. */ + DEAL_II_DEPRECATED NonlinearSolverSelector(const AdditionalData &additional_data); /** @@ -482,7 +485,9 @@ NonlinearSolverSelector::set_data( template -NonlinearSolverSelector::NonlinearSolverSelector() = default; +NonlinearSolverSelector::NonlinearSolverSelector() + : mpi_communicator(MPI_COMM_SELF) +{} @@ -490,6 +495,7 @@ template NonlinearSolverSelector::NonlinearSolverSelector( const AdditionalData &additional_data) : additional_data(additional_data) + , mpi_communicator(MPI_COMM_SELF) { set_data(additional_data); } diff --git a/tests/numerics/nonlinear_solver_selector_01.cc b/tests/numerics/nonlinear_solver_selector_01.cc index afae2cfe8b..37d7ff3774 100644 --- a/tests/numerics/nonlinear_solver_selector_01.cc +++ b/tests/numerics/nonlinear_solver_selector_01.cc @@ -358,7 +358,7 @@ namespace nonlinear_solver_selector_test typename NLSolve::AdditionalData additional_data; additional_data.solver_type = SOLVER; - NLSolve nonlinear_solver(additional_data); + NLSolve nonlinear_solver(additional_data, MPI_COMM_WORLD); nonlinear_solver.reinit_vector = [&](Vector &x) { x.reinit(dof_handler.n_dofs()); -- 2.39.5