From 8f00abbfd3c4b64ef5f238769e63b1fd481b6280 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 4 Jun 2026 11:23:55 +0200 Subject: [PATCH] Guard FLD/NONE injection group constraint path --- opm/simulators/wells/GroupConstraintCalculator.cpp | 6 ++++++ opm/simulators/wells/GroupStateHelper.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/GroupConstraintCalculator.cpp b/opm/simulators/wells/GroupConstraintCalculator.cpp index b25ec8457c..53b916c7a6 100644 --- a/opm/simulators/wells/GroupConstraintCalculator.cpp +++ b/opm/simulators/wells/GroupConstraintCalculator.cpp @@ -341,6 +341,12 @@ getGroupConstraintNoGuideRate(const Group& group) // to the slave group. Alternatively, we could also throw an error here for that case if (this->isInjectionConstraint()) { const auto& control_mode = this->groupState().injection_control(group.name(), this->injectionPhase_()); + // FLD/NONE means no own local constraint for this phase. + // Let the caller use a higher-level distributed target instead. + if (control_mode == Group::InjectionCMode::FLD || + control_mode == Group::InjectionCMode::NONE) { + return std::nullopt; + } return ConstraintInfo{ this->groupStateHelper().getInjectionGroupTarget(group, this->injectionPhase_(), this->resvCoeffsInj()), control_mode diff --git a/opm/simulators/wells/GroupStateHelper.cpp b/opm/simulators/wells/GroupStateHelper.cpp index a62022580b..8372a9ee67 100644 --- a/opm/simulators/wells/GroupStateHelper.cpp +++ b/opm/simulators/wells/GroupStateHelper.cpp @@ -2017,7 +2017,9 @@ getInjectionGroupTargetForMode_( } default: OPM_DEFLOG_THROW(std::logic_error, - "Invalid Group::InjectionCMode in getInjectionGroupTargetForMode_", + fmt::format("Invalid Group::InjectionCMode in getInjectionGroupTargetForMode_ for {} cmode: {}", + group.name(), + Group::InjectionCMode2String(cmode)), this->deferredLogger()); return 0.0; }