From 97367a1e951da317647d4af4cafb0b0da85339f7 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 21 Oct 2022 09:34:36 +0200 Subject: [PATCH] move checkIndividualConstraints to WellConstraints --- opm/simulators/wells/WellConstraints.cpp | 31 +++++++++++++++++++ opm/simulators/wells/WellConstraints.hpp | 9 +++++- .../wells/WellInterfaceFluidSystem.cpp | 27 +++------------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/opm/simulators/wells/WellConstraints.cpp b/opm/simulators/wells/WellConstraints.cpp index 35a662342..43468169e 100644 --- a/opm/simulators/wells/WellConstraints.cpp +++ b/opm/simulators/wells/WellConstraints.cpp @@ -32,6 +32,37 @@ namespace Opm { +bool WellConstraints:: +checkIndividualConstraints(SingleWellState& ws, + const SummaryState& summaryState, + const RateConvFunc& calcReservoirVoidageRates, + bool& thp_limit_violated_but_not_switched, + DeferredLogger& deferred_logger) const +{ + if (well_.isProducer()) { + auto new_cmode = this->activeProductionConstraint(ws, summaryState, + calcReservoirVoidageRates, + thp_limit_violated_but_not_switched, + deferred_logger); + if (new_cmode != ws.production_cmode) { + ws.production_cmode = new_cmode; + return true; + } + } + + if (well_.isInjector()) { + auto new_cmode = this->activeInjectionConstraint(ws, summaryState, + thp_limit_violated_but_not_switched, + deferred_logger); + if (new_cmode != ws.injection_cmode) { + ws.injection_cmode = new_cmode; + return true; + } + } + + return false; +} + Well::InjectorCMode WellConstraints:: activeInjectionConstraint(const SingleWellState& ws, const SummaryState& summaryState, diff --git a/opm/simulators/wells/WellConstraints.hpp b/opm/simulators/wells/WellConstraints.hpp index 030c7a10f..ce29284ab 100644 --- a/opm/simulators/wells/WellConstraints.hpp +++ b/opm/simulators/wells/WellConstraints.hpp @@ -49,6 +49,14 @@ public: const std::vector&, std::vector&)>; + bool + checkIndividualConstraints(SingleWellState& ws, + const SummaryState& summaryState, + const RateConvFunc& calcReservoirVoidageRates, + bool& thp_limit_violated_but_not_switched, + DeferredLogger& deferred_logger) const; + +private: Well::InjectorCMode activeInjectionConstraint(const SingleWellState& ws, const SummaryState& summaryState, @@ -62,7 +70,6 @@ public: bool& thp_limit_violated_but_not_switched, DeferredLogger& deferred_logger) const; -private: const WellInterfaceGeneric& well_; //!< Reference to well interface }; diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.cpp b/opm/simulators/wells/WellInterfaceFluidSystem.cpp index efa9fa79a..90eb3f447 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -98,29 +98,10 @@ checkIndividualConstraints(SingleWellState& ws, surface_rates, voidage_rates); }; - if (this->well_ecl_.isProducer()) { - auto new_cmode = WellConstraints(*this).activeProductionConstraint(ws, summaryState, - rRates, - this->operability_status_.thp_limit_violated_but_not_switched, - deferred_logger); - if (new_cmode != ws.production_cmode) { - ws.production_cmode = new_cmode; - return true; - } - } - - if (this->well_ecl_.isInjector()) { - auto new_cmode = WellConstraints(*this). - activeInjectionConstraint(ws, summaryState, - this->operability_status_.thp_limit_violated_but_not_switched, - deferred_logger); - if (new_cmode != ws.injection_cmode) { - ws.injection_cmode = new_cmode; - return true; - } - } - - return false; + return WellConstraints(*this). + checkIndividualConstraints(ws, summaryState, rRates, + this->operability_status_.thp_limit_violated_but_not_switched, + deferred_logger); } template