OGS
NumLib::anonymous_namespace{NonlinearSolver.cpp} Namespace Reference

Functions

template<typename Assemble>
bool assembledOnAllRanks (Assemble const &assemble)

Function Documentation

◆ assembledOnAllRanks()

template<typename Assemble>
bool NumLib::anonymous_namespace{NonlinearSolver.cpp}::assembledOnAllRanks ( Assemble const & assemble)

Runs assemble and reconciles a NumLib::AssemblyException thrown by it across all MPI ranks.

Returns
Whether the assembly succeeded on every rank.

Do not remove the reconciliation across ranks: a rank that carried on while another one aborted would block in the collective calls of the subsequent linear solve and deadlock the simulation. The reconciliation itself is not covered by a test: the unit tests in Tests/NumLib/TestNonlinearSolverAssemblyException.cpp run on a single rank, and they are disabled in PETSc builds altogether (issue #1989).

Definition at line 97 of file NonlinearSolver.cpp.

98{
99 bool mpi_rank_assembly_ok = true;
100 try
101 {
102 assemble();
103 }
104 catch (AssemblyException const& e)
105 {
106 ERR("Abort nonlinear iteration. Repeating timestep. Reason: {:s}",
107 e.what());
108 mpi_rank_assembly_ok = false;
109 }
110 return !BaseLib::MPI::anyOf(!mpi_rank_assembly_ok);
111}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
static bool anyOf(bool const val, Mpi const &mpi=Mpi{OGS_COMM_WORLD})
Definition MPI.h:174

References BaseLib::MPI::anyOf(), assembledOnAllRanks(), and ERR().

Referenced by assembledOnAllRanks().