From 779dd74923a49f4478ac07a8fca8e01842d07d26 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 4 Dec 2023 16:49:39 +0100 Subject: [PATCH] Communicate exceptions during WellModel::updateAndCommunicate For multi segment well the underlying call to MultisegmentWell::updateWellStateWithTarget (at least if updateWellStateWithTHPTargetProd is called for a producer under thp control) might throw as there might be a singular matrix during the solve needed in MultisegmentWell::iterateWellEqWithControl. Previously, if that happened then the MPI process where it happened would stop the nonlinear iteration as failed and try with a chopped time step. The others might go one with the current time step and we would see MPI errors about truncated messages. Now we communicate any exception happening during this part of WellModel::updateAndCommunicate and all processes will stop the nonlinear iteration as failed and chop the time step. --- 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 7beb4b9915..0ee2f2109d 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -2144,10 +2144,16 @@ namespace Opm { DeferredLogger& deferred_logger) { updateAndCommunicateGroupData(reportStepIdx, iterationIdx); + + // updateWellStateWithTarget might throw for multisegment wells hence we + // have a parallel try catch here to thrown on all processes. + OPM_BEGIN_PARALLEL_TRY_CATCH() // if a well or group change control it affects all wells that are under the same group for (const auto& well : well_container_) { well->updateWellStateWithTarget(ebosSimulator_, this->groupState(), this->wellState(), deferred_logger); } + OPM_END_PARALLEL_TRY_CATCH("BlackoilWellModel::updateAndCommunicate failed: ", + ebosSimulator_.gridView().comm()) updateAndCommunicateGroupData(reportStepIdx, iterationIdx); }