From 50c25ead52c3e75709aa95f92dcf536fda1f1d3c Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Sat, 25 Nov 2023 18:22:28 +0100 Subject: [PATCH] [bugfix] Expect singular matrices and terminate updateWellControls. We are experiencing singular matrices when solving mulisegment wells sometimes. In that case (here during BlackoilModelEbos::assembleReservoir <- BlackoilModelEbos::initialLinerization <- BlackoilModelEbos:::nonlinearIterationNewton ) an exception is thrown when updating the controls of a well. The problem here is that this exception only happens on one process. That one goes to the catch block in NonLinearSolverEbos::step, marks the nonlinear solve as failed and cuts the time step. The others move to the collective communication below. Somehow and somewhen all end up in a non-matching collective communication with different data types and we get an MPI Error that the message was truncated. Now all processes will throw, terminate the nonlinear solver and cut the timestep as it should be. --- opm/simulators/wells/BlackoilWellModel_impl.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index a58877540..c9eaf4982 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -1932,6 +1932,9 @@ namespace Opm { // Check individual well constraints and communicate. bool changed_well_individual = false; + // For MS Wells a linear solve is performed below and the matrix might be singular. + // We need to communicate the exception thrown to the others and rethrow. + OPM_BEGIN_PARALLEL_TRY_CATCH() for (const auto& well : well_container_) { const auto mode = WellInterface::IndividualOrGroup::Individual; const bool changed_well = well->updateWellControl(ebosSimulator_, mode, this->wellState(), this->groupState(), deferred_logger); @@ -1939,6 +1942,9 @@ namespace Opm { changed_well_individual = changed_well || changed_well_individual; } } + OPM_END_PARALLEL_TRY_CATCH("BlackoilWellModel: updating well controls failed: ", + ebosSimulator_.gridView().comm()); + changed_well_individual = comm.sum(static_cast(changed_well_individual)); if (changed_well_individual) { updateAndCommunicate(episodeIdx, iterationIdx, deferred_logger);