diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index d6b802aaf..9ac30bb5a 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -2377,14 +2377,28 @@ runWellPIScaling(const int timeStepIdx, bool BlackoilWellModelGeneric:: -guideRateUpdateIsNeeded() const { - const auto need_update = +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(); + const 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, effective_events_mask](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 a5a812317..f4ec6cdf6 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.hpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.hpp @@ -396,7 +396,7 @@ protected: const SummaryConfig& summaryConfig, DeferredLogger& deferred_logger); - bool guideRateUpdateIsNeeded() const; + bool guideRateUpdateIsNeeded(const int reportStepIdx) const; // create the well container virtual void createWellContainer(const int time_step) = 0; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 7f161c159..c6e41980b 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -842,8 +842,8 @@ namespace Opm { terminal_output_, grid().comm()); //update guide rates - if (guideRateUpdateIsNeeded()) { - const int reportStepIdx = ebosSimulator_.episodeIndex(); + const int reportStepIdx = ebosSimulator_.episodeIndex(); + if (guideRateUpdateIsNeeded(reportStepIdx)) { const double simulationTime = ebosSimulator_.time(); const auto& comm = ebosSimulator_.vanguard().grid().comm(); const auto& summaryState = ebosSimulator_.vanguard().summaryState();