From 35386a79bf6af03fc8d174a3ed6e1e57144256aa Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 24 Oct 2022 09:36:05 +0200 Subject: [PATCH] move loadRestartGuideRates(Config) into BlackoilWellModelRestart --- .../wells/BlackoilWellModelGeneric.cpp | 60 ++----------------- .../wells/BlackoilWellModelGeneric.hpp | 4 -- .../wells/BlackoilWellModelRestart.cpp | 25 ++++++++ .../wells/BlackoilWellModelRestart.hpp | 7 +++ 4 files changed, 36 insertions(+), 60 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index f48bed7e9..991a233f9 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -57,36 +57,6 @@ #include namespace { - Opm::data::GuideRateValue::Item - guideRateRestartItem(const Opm::GuideRateModel::Target target) - { - using Item = Opm::data::GuideRateValue::Item; - using Target = Opm::GuideRateModel::Target; - - static const auto items = std::unordered_map { - { Target::OIL, Item::Oil }, - { Target::GAS, Item::Gas }, - { Target::WAT, Item::Water }, - { Target::RES, Item::ResV }, - }; - - auto i = items.find(target); - return (i == items.end()) ? Item::NumItems : i->second; - } - - Opm::GuideRate::GuideRateValue - makeGuideRateValue(const Opm::data::GuideRateValue& restart, - const Opm::GuideRateModel::Target target) - { - const auto item = guideRateRestartItem(target); - - if (! restart.has(item)) { - return {}; - } - - return { 0.0, restart.get(item), target }; - } - struct RetrieveWellGuideRate { RetrieveWellGuideRate() = default; @@ -415,29 +385,6 @@ getWellEcl(const std::string& well_name) const return *well_ecl; } -void -BlackoilWellModelGeneric:: -loadRestartGuideRates(const int report_step, - const GuideRateConfig& config, - const std::map& rst_groups) -{ - const auto target = config.model().target(); - - for (const auto& [group_name, rst_group] : rst_groups) { - if (! config.has_production_group(group_name)) { - continue; - } - - const auto& group = config.production_group(group_name); - if ((group.guide_rate > 0.0) || (group.target != Group::GuideRateProdTarget::FORM)) { - continue; - } - - this->guideRate_.init_grvalue_SI(report_step, group_name, - makeGuideRateValue(rst_group.guideRates.production, target)); - } -} - void BlackoilWellModelGeneric:: loadRestartData(const data::Wells& rst_wells, @@ -521,12 +468,14 @@ initFromRestartFile(const RestartValue& restartValues, } if (config.has_model()) { - this->loadRestartGuideRates(report_step, config, restartValues.grp_nwrk.groupData); + BlackoilWellModelRestart(*this).loadRestartGuideRates(report_step, + config, + restartValues.grp_nwrk.groupData, + this->guideRate_); this->guideRate_.updateGuideRateExpiration(this->schedule().seconds(report_step), report_step); } - this->active_wgstate_.wtest_state(std::move(wtestState)); this->commitWGState(); initial_step_ = false; @@ -1146,7 +1095,6 @@ checkGroupHigherConstraints(const Group& group, changed = true; } } - } return changed; diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index a25e635e3..933f410dd 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -286,10 +286,6 @@ protected: std::map& gvalues) const; void assignNodeValues(std::map& nodevalues) const; - void loadRestartGuideRates(const int report_step, - const GuideRateConfig& config, - const std::map& rst_groups); - std::unordered_map calculateAllGroupGuiderates(const int reportStepIdx) const; diff --git a/opm/simulators/wells/BlackoilWellModelRestart.cpp b/opm/simulators/wells/BlackoilWellModelRestart.cpp index a888c3a08..357d30dcb 100644 --- a/opm/simulators/wells/BlackoilWellModelRestart.cpp +++ b/opm/simulators/wells/BlackoilWellModelRestart.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include @@ -192,4 +194,27 @@ loadRestartGuideRates(const int report_step, } } +void BlackoilWellModelRestart:: +loadRestartGuideRates(const int report_step, + const GuideRateConfig& config, + const std::map& rst_groups, + GuideRate& guide_rate) const +{ + const auto target = config.model().target(); + + for (const auto& [group_name, rst_group] : rst_groups) { + if (!config.has_production_group(group_name)) { + continue; + } + + const auto& group = config.production_group(group_name); + if ((group.guide_rate > 0.0) || (group.target != Group::GuideRateProdTarget::FORM)) { + continue; + } + + guide_rate.init_grvalue_SI(report_step, group_name, + makeGuideRateValue(rst_group.guideRates.production, target)); + } +} + } // namespace Opm diff --git a/opm/simulators/wells/BlackoilWellModelRestart.hpp b/opm/simulators/wells/BlackoilWellModelRestart.hpp index 88b9ae86b..444c5b344 100644 --- a/opm/simulators/wells/BlackoilWellModelRestart.hpp +++ b/opm/simulators/wells/BlackoilWellModelRestart.hpp @@ -36,6 +36,7 @@ class GroupData; } class GroupState; class GuideRate; +class GuideRateConfig; struct PerforationData; class SingleWellState; @@ -67,6 +68,12 @@ public: const data::Wells& rst_wells, GuideRate& guide_rate) const; + //! \brief Loads guide rates from restart structures. + void loadRestartGuideRates(const int report_step, + const GuideRateConfig& config, + const std::map& rst_groups, + GuideRate& guide_rate) const; + private: //! \brief Loads per-connection data from restart structures. void loadRestartConnectionData(const std::vector& phs,