]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix NonlinearSolverSelector MPI_COMM 17355/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 22 Jul 2024 21:27:30 +0000 (17:27 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 23 Jul 2024 17:58:13 +0000 (13:58 -0400)
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
tests/numerics/nonlinear_solver_selector_01.cc

index 9ec2dfd10c47c6bb3c8ff40ef25c25899a89c6d6..bde8ee41b6a90616cf68a5a758013ced3b228e4a 100644 (file)
@@ -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<VectorType>::set_data(
 
 
 template <typename VectorType>
-NonlinearSolverSelector<VectorType>::NonlinearSolverSelector() = default;
+NonlinearSolverSelector<VectorType>::NonlinearSolverSelector()
+  : mpi_communicator(MPI_COMM_SELF)
+{}
 
 
 
@@ -490,6 +495,7 @@ template <typename VectorType>
 NonlinearSolverSelector<VectorType>::NonlinearSolverSelector(
   const AdditionalData &additional_data)
   : additional_data(additional_data)
+  , mpi_communicator(MPI_COMM_SELF)
 {
   set_data(additional_data);
 }
index afae2cfe8b95622c5a2d95b9f4b609d5edebcb90..37d7ff37744bbb1f61eb682c2432dcd0a032f9e3 100644 (file)
@@ -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<double> &x) {
         x.reinit(dof_handler.n_dofs());

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.