From 9f78e0454d10f91db3bf6e3dcd5159dc9b7d2068 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Mon, 24 Oct 2022 09:36:05 +0200 Subject: [PATCH] move guideRateUpdateIsNeeded into BlackoilWellModelGuideRates --- .../wells/BlackoilWellModelGeneric.cpp | 29 ------------------- .../wells/BlackoilWellModelGeneric.hpp | 2 -- .../wells/BlackoilWellModelGuideRates.cpp | 25 ++++++++++++++++ .../wells/BlackoilWellModelGuideRates.hpp | 3 ++ .../wells/BlackoilWellModel_impl.hpp | 3 +- 5 files changed, 30 insertions(+), 32 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index d83ff4872..e45e87e2e 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1191,33 +1191,4 @@ runWellPIScaling(const int timeStepIdx, this->last_run_wellpi_ = timeStepIdx; } - -bool -BlackoilWellModelGeneric:: -guideRateUpdateIsNeeded(const int reportStepIdx) const { - auto need_update = - std::any_of(this->well_container_generic_.begin(), - this->well_container_generic_.end(), - [](const WellInterfaceGeneric* well) - { - return well->changedToOpenThisStep(); - }); - if (!need_update && this->report_step_starts_) { - const auto& events = this->schedule()[reportStepIdx].wellgroup_events(); - constexpr auto effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE - + ScheduleEvents::INJECTION_TYPE_CHANGED - + ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER - + ScheduleEvents::NEW_WELL; - - need_update = std::any_of(this->well_container_generic_.begin(), - this->well_container_generic_.end(), - [&events](const WellInterfaceGeneric* well) - { - return events.hasEvent(well->name(), effective_events_mask); - }); - } - return this->comm_.max(static_cast(need_update)); -} - - } diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.hpp b/opm/simulators/wells/BlackoilWellModelGeneric.hpp index 937e1f339..48fd43362 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -320,8 +320,6 @@ protected: const SummaryConfig& summaryConfig, DeferredLogger& deferred_logger); - bool guideRateUpdateIsNeeded(const int reportStepIdx) const; - // create the well container virtual void createWellContainer(const int time_step) = 0; virtual void initWellContainer(const int reportStepIdx) = 0; diff --git a/opm/simulators/wells/BlackoilWellModelGuideRates.cpp b/opm/simulators/wells/BlackoilWellModelGuideRates.cpp index aff76ded3..fc0558274 100644 --- a/opm/simulators/wells/BlackoilWellModelGuideRates.cpp +++ b/opm/simulators/wells/BlackoilWellModelGuideRates.cpp @@ -569,5 +569,30 @@ assignGroupGuideRates(const Group& group, } } +bool BlackoilWellModelGuideRates:: +guideRateUpdateIsNeeded(const int reportStepIdx) const +{ + const auto& genWells = wellModel_.genericWells(); + auto need_update = + std::any_of(genWells.begin(), genWells.end(), + [](const WellInterfaceGeneric* well) + { + return well->changedToOpenThisStep(); + }); + if (!need_update && wellModel_.reportStepStarts()) { + const auto& events = wellModel_.schedule()[reportStepIdx].wellgroup_events(); + constexpr auto effective_events_mask = ScheduleEvents::WELL_STATUS_CHANGE + + ScheduleEvents::INJECTION_TYPE_CHANGED + + ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER + + ScheduleEvents::NEW_WELL; + + need_update = std::any_of(genWells.begin(), genWells.end(), + [&events](const WellInterfaceGeneric* well) + { + return events.hasEvent(well->name(), effective_events_mask); + }); + } + return wellModel_.comm().max(static_cast(need_update)); +} } // namespace Opm diff --git a/opm/simulators/wells/BlackoilWellModelGuideRates.hpp b/opm/simulators/wells/BlackoilWellModelGuideRates.hpp index 6287f6009..d481b14e4 100644 --- a/opm/simulators/wells/BlackoilWellModelGuideRates.hpp +++ b/opm/simulators/wells/BlackoilWellModelGuideRates.hpp @@ -62,6 +62,9 @@ public: const std::unordered_map& groupGuideRates, data::GroupData& gdata) const; + //! \brief Check if a guide rate update is needed. + bool guideRateUpdateIsNeeded(const int reportStepIdx) const; + private: //! \brief Obtain guide rate values. void getGuideRateValues(const GuideRate::RateVector& qs, diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 1a4ed8feb..1e9e249e4 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -918,7 +918,8 @@ namespace Opm { //update guide rates const int reportStepIdx = ebosSimulator_.episodeIndex(); - if (alq_updated || guideRateUpdateIsNeeded(reportStepIdx)) { + if (alq_updated || BlackoilWellModelGuideRates(*this). + guideRateUpdateIsNeeded(reportStepIdx)) { const double simulationTime = ebosSimulator_.time(); const auto& comm = ebosSimulator_.vanguard().grid().comm(); const auto& summaryState = ebosSimulator_.vanguard().summaryState();