From: Timo Heister Date: Mon, 22 Jul 2024 21:27:30 +0000 (-0400) Subject: fix NonlinearSolverSelector MPI_COMM X-Git-Tag: v9.6.0-rc1~8^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17355%2Fhead;p=dealii.git 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. --- 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());