From 75dad9f4c4543dfd08de98ea3cdb7609e7df9139 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 24 Oct 2022 09:36:05 +0200 Subject: [PATCH] move checkGroupConstraintsProd into WellGroupConstraints --- opm/simulators/wells/WellGroupConstraints.cpp | 32 ++++++++++++++ opm/simulators/wells/WellGroupConstraints.hpp | 10 +++++ .../wells/WellInterfaceFluidSystem.cpp | 43 ++++--------------- .../wells/WellInterfaceFluidSystem.hpp | 8 ---- 4 files changed, 51 insertions(+), 42 deletions(-) diff --git a/opm/simulators/wells/WellGroupConstraints.cpp b/opm/simulators/wells/WellGroupConstraints.cpp index 3bfedfb28..86b0dd6e7 100644 --- a/opm/simulators/wells/WellGroupConstraints.cpp +++ b/opm/simulators/wells/WellGroupConstraints.cpp @@ -91,4 +91,36 @@ checkGroupConstraintsInj(const Group& group, deferred_logger); } +std::pair +WellGroupConstraints:: +checkGroupConstraintsProd(const Group& group, + const WellState& well_state, + const GroupState& group_state, + const double efficiencyFactor, + const Schedule& schedule, + const SummaryState& summaryState, + const RateConvFunc& rateConverter, + DeferredLogger& deferred_logger) const +{ + // Make conversion factors for RESV <-> surface rates. + std::vector resv_coeff(well_.phaseUsage().num_phases, 1.0); + rateConverter(0, well_.pvtRegionIdx(), resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS. + + const auto& ws = well_state.well(well_.indexOfWell()); + return WellGroupHelpers::checkGroupConstraintsProd(well_.name(), + well_.wellEcl().groupName(), + group, + well_state, + group_state, + well_.currentStep(), + well_.guideRate(), + ws.surface_rates.data(), + well_.phaseUsage(), + efficiencyFactor, + schedule, + summaryState, + resv_coeff, + deferred_logger); +} + } // namespace Opm diff --git a/opm/simulators/wells/WellGroupConstraints.hpp b/opm/simulators/wells/WellGroupConstraints.hpp index c9739feab..714367cd3 100644 --- a/opm/simulators/wells/WellGroupConstraints.hpp +++ b/opm/simulators/wells/WellGroupConstraints.hpp @@ -59,6 +59,16 @@ public: const RateConvFunc& rateConverter, DeferredLogger& deferred_logger) const; + std::pair + checkGroupConstraintsProd(const Group& group, + const WellState& well_state, + const GroupState& group_state, + const double efficiencyFactor, + const Schedule& schedule, + const SummaryState& summaryState, + const RateConvFunc& rateConverter, + 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 0a87a0481..bfba6480d 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -327,38 +327,6 @@ checkIndividualConstraints(SingleWellState& ws, return false; } -template -std::pair -WellInterfaceFluidSystem:: -checkGroupConstraintsProd(const Group& group, - const WellState& well_state, - const GroupState& group_state, - const double efficiencyFactor, - const Schedule& schedule, - const SummaryState& summaryState, - DeferredLogger& deferred_logger) const -{ - // Make conversion factors for RESV <-> surface rates. - std::vector resv_coeff(this->phaseUsage().num_phases, 1.0); - rateConverter_.calcCoeff(0, pvtRegionIdx_, resv_coeff); // FIPNUM region 0 here, should use FIPNUM from WELSPECS. - - const auto& ws = well_state.well(this->index_of_well_); - return WellGroupHelpers::checkGroupConstraintsProd(name(), - well_ecl_.groupName(), - group, - well_state, - group_state, - current_step_, - guide_rate_, - ws.surface_rates.data(), - phaseUsage(), - efficiencyFactor, - schedule, - summaryState, - resv_coeff, - deferred_logger); -} - template bool WellInterfaceFluidSystem:: @@ -425,8 +393,15 @@ checkGroupConstraints(WellState& well_state, const auto& group = schedule.getGroup( well.groupName(), current_step_ ); const double efficiencyFactor = well.getEfficiencyFactor(); const std::pair group_constraint = - checkGroupConstraintsProd(group, well_state, group_state, efficiencyFactor, - schedule, summaryState, deferred_logger); + WellGroupConstraints(*this). + checkGroupConstraintsProd(group, + well_state, + group_state, + efficiencyFactor, + schedule, + summaryState, + rCoeff, + deferred_logger); // If a group constraint was broken, we set the current well control to // be GRUP. if (group_constraint.first) { diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.hpp b/opm/simulators/wells/WellInterfaceFluidSystem.hpp index abf8a222f..18f2ec8eb 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.hpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.hpp @@ -89,14 +89,6 @@ protected: const SummaryState& summaryState, DeferredLogger& deferred_logger) const; - std::pair checkGroupConstraintsProd(const Group& group, - const WellState& well_state, - const GroupState& group_state, - const double efficiencyFactor, - const Schedule& schedule, - const SummaryState& summaryState, - DeferredLogger& deferred_logger) const; - bool checkGroupConstraints(WellState& well_state, const GroupState& group_state, const Schedule& schedule,