diff --git a/opm/simulators/wells/WellBhpThpCalculator.cpp b/opm/simulators/wells/WellBhpThpCalculator.cpp index 835a4776d..559a8e93a 100644 --- a/opm/simulators/wells/WellBhpThpCalculator.cpp +++ b/opm/simulators/wells/WellBhpThpCalculator.cpp @@ -48,4 +48,20 @@ WellBhpThpCalculator::wellHasTHPConstraints(const SummaryState& summaryState) co return false; } +double WellBhpThpCalculator::getTHPConstraint(const SummaryState& summaryState) const +{ + const auto& well_ecl = well_.wellEcl(); + if (well_ecl.isInjector()) { + const auto& controls = well_ecl.injectionControls(summaryState); + return controls.thp_limit; + } + + if (well_ecl.isProducer( )) { + const auto& controls = well_ecl.productionControls(summaryState); + return controls.thp_limit; + } + + return 0.0; +} + } // namespace Opm diff --git a/opm/simulators/wells/WellBhpThpCalculator.hpp b/opm/simulators/wells/WellBhpThpCalculator.hpp index f4b3e3afc..3794e326c 100644 --- a/opm/simulators/wells/WellBhpThpCalculator.hpp +++ b/opm/simulators/wells/WellBhpThpCalculator.hpp @@ -44,6 +44,9 @@ public: //! \brief Checks if well has THP constraints. bool wellHasTHPConstraints(const SummaryState& summaryState) const; + //! \brief Get THP constraint for well. + double getTHPConstraint(const SummaryState& summaryState) const; + private: const WellInterfaceGeneric& well_; //!< Reference to well interface }; diff --git a/opm/simulators/wells/WellInterfaceGeneric.cpp b/opm/simulators/wells/WellInterfaceGeneric.cpp index e871235b5..9d079e948 100644 --- a/opm/simulators/wells/WellInterfaceGeneric.cpp +++ b/opm/simulators/wells/WellInterfaceGeneric.cpp @@ -227,17 +227,8 @@ double WellInterfaceGeneric::getTHPConstraint(const SummaryState& summaryState) if (dynamic_thp_limit_) { return *dynamic_thp_limit_; } - if (well_ecl_.isInjector()) { - const auto& controls = well_ecl_.injectionControls(summaryState); - return controls.thp_limit; - } - if (well_ecl_.isProducer( )) { - const auto& controls = well_ecl_.productionControls(summaryState); - return controls.thp_limit; - } - - return 0.0; + return WellBhpThpCalculator(*this).getTHPConstraint(summaryState); } bool WellInterfaceGeneric::underPredictionMode() const