From 237eb2b7ee7f5aa750cd805d3a45c40166cad080 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Sun, 10 Jan 2021 21:46:45 +0100 Subject: [PATCH] Fetch events from ScheduleState --- ebos/eclproblem.hh | 20 +++++++++---------- ebos/eclwellmanager.hh | 10 ++++------ .../SimulatorFullyImplicitBlackoilEbos.hpp | 12 +++++------ .../wells/BlackoilWellModel_impl.hpp | 11 +++++----- opm/simulators/wells/WellGroupHelpers.cpp | 5 +++-- .../wells/WellStateFullyImplicitBlackoil.hpp | 2 +- 6 files changed, 29 insertions(+), 31 deletions(-) diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index 66ac92074..a3f2ce300 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -1019,18 +1019,18 @@ public: int episodeIdx = simulator.episodeIndex(); auto& eclState = simulator.vanguard().eclState(); const auto& schedule = simulator.vanguard().schedule(); - const auto& events = schedule.getEvents(); + const auto& events = schedule[episodeIdx].events(); const auto& timeMap = schedule.getTimeMap(); - if (episodeIdx >= 0 && events.hasEvent(Opm::ScheduleEvents::GEO_MODIFIER, episodeIdx)) { + if (episodeIdx >= 0 && events.hasEvent(Opm::ScheduleEvents::GEO_MODIFIER)) { // bring the contents of the keywords to the current state of the SCHEDULE // section. // // TODO (?): make grid topology changes possible (depending on what exactly // has changed, the grid may need be re-created which has some serious // implications on e.g., the solution of the simulation.) - const auto& miniDeck = schedule.getModifierDeck(episodeIdx); - eclState.applyModifierDeck(miniDeck); + const auto& miniDeck = schedule[episodeIdx].geo_keywords(); + eclState.apply_geo_keywords( miniDeck ); // re-compute all quantities which may possibly be affected. transmissibilities_.update(true); @@ -1058,7 +1058,7 @@ public: // react to TUNING changes bool tuningEvent = false; - if (episodeIdx > 0 && enableTuning_ && events.hasEvent(Opm::ScheduleEvents::TUNING_CHANGE, episodeIdx)) + if (episodeIdx > 0 && enableTuning_ && events.hasEvent(Opm::ScheduleEvents::TUNING_CHANGE)) { const auto& tuning = schedule[episodeIdx].tuning(); initialTimeStepSize_ = tuning.TSINIT; @@ -3243,7 +3243,6 @@ private: return dtNext; const auto& simulator = this->simulator(); - const auto& events = simulator.vanguard().schedule().getEvents(); int episodeIdx = simulator.episodeIndex(); // first thing in the morning, limit the time step size to the maximum size @@ -3265,11 +3264,12 @@ private: // if a well event occured, respect the limit for the maximum time step after // that, too int reportStepIdx = std::max(episodeIdx, 0); + const auto& events = simulator.vanguard().schedule()[reportStepIdx].events(); bool wellEventOccured = - events.hasEvent(Opm::ScheduleEvents::NEW_WELL, reportStepIdx) - || events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE, reportStepIdx) - || events.hasEvent(Opm::ScheduleEvents::INJECTION_UPDATE, reportStepIdx) - || events.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE, reportStepIdx); + events.hasEvent(Opm::ScheduleEvents::NEW_WELL) + || events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE) + || events.hasEvent(Opm::ScheduleEvents::INJECTION_UPDATE) + || events.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE); if (episodeIdx >= 0 && wellEventOccured && maxTimeStepAfterWellEvent_ > 0) dtNext = std::min(dtNext, maxTimeStepAfterWellEvent_); } diff --git a/ebos/eclwellmanager.hh b/ebos/eclwellmanager.hh index 19749c0f4..5dfedfbf4 100644 --- a/ebos/eclwellmanager.hh +++ b/ebos/eclwellmanager.hh @@ -609,11 +609,10 @@ public: // for the "until the universe dies" episode, the wells don't change return false; - const Opm::Events& events = schedule.getEvents(); + const Opm::Events& events = schedule[reportStepIdx].events(); return events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE | Opm::ScheduleEvents::INJECTION_UPDATE | - Opm::ScheduleEvents::WELL_STATUS_CHANGE, - reportStepIdx); + Opm::ScheduleEvents::WELL_STATUS_CHANGE ); } void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){ @@ -636,10 +635,9 @@ protected: // for the "until the universe dies" episode, the wells don't change return false; - const Opm::Events& events = schedule.getEvents(); + const Opm::Events& events = schedule[reportStepIdx].events(); return events.hasEvent(Opm::ScheduleEvents::NEW_WELL | - Opm::ScheduleEvents::COMPLETION_CHANGE, - reportStepIdx); + Opm::ScheduleEvents::COMPLETION_CHANGE); } void updateWellTopology_(unsigned reportStepIdx OPM_UNUSED, diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp index 9ca5d3d1c..61f7bc653 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp @@ -235,7 +235,6 @@ public: timer.currentStepLength()); ebosSimulator_.setEpisodeIndex(timer.currentStepNum()); solver->model().beginReportStep(); - const auto& events = schedule().getEvents(); bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, EnableTuning); // If sub stepping is enabled allow the solver to sub cycle @@ -244,16 +243,17 @@ public: // \Note: The report steps are met in any case // \Note: The sub stepping will require a copy of the state variables if (adaptiveTimeStepping_) { + const auto& events = schedule()[timer.currentStepNum()].events(); if (enableTUNING) { - if (events.hasEvent(ScheduleEvents::TUNING_CHANGE,timer.currentStepNum())) { + if (events.hasEvent(ScheduleEvents::TUNING_CHANGE)) { adaptiveTimeStepping_->updateTUNING(schedule()[timer.currentStepNum()].tuning()); } } - bool event = events.hasEvent(ScheduleEvents::NEW_WELL, timer.currentStepNum()) || - events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE, timer.currentStepNum()) || - events.hasEvent(ScheduleEvents::INJECTION_UPDATE, timer.currentStepNum()) || - events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE, timer.currentStepNum()); + bool event = events.hasEvent(ScheduleEvents::NEW_WELL) || + events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE) || + events.hasEvent(ScheduleEvents::INJECTION_UPDATE) || + events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE); auto stepReport = adaptiveTimeStepping_->step(timer, *solver, event, nullptr); report_ += stepReport; } else { diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 5a62dea28..48466aa82 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -282,7 +282,7 @@ namespace Opm { + ScheduleEvents::INJECTION_UPDATE + ScheduleEvents::NEW_WELL; - if(!schedule().hasWellGroupEvent(well.name(), effective_events_mask, timeStepIdx)) + if(!schedule()[timeStepIdx].wellgroup_events().hasEvent(well.name(), effective_events_mask)) continue; if (well.isProducer()) { @@ -308,7 +308,7 @@ namespace Opm { schedule().getVFPProdTables(timeStepIdx)) ); this->initializeWellProdIndCalculators(); - if (this->schedule().getEvents().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX, timeStepIdx)) { + if (this->schedule()[timeStepIdx].events().hasEvent(ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX)) { this->runWellPIScaling(timeStepIdx, local_deferredLogger); } @@ -2628,10 +2628,9 @@ namespace Opm { auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool { - return this->schedule() - .hasWellGroupEvent(this->wells_ecl_[well_index].name(), - ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX, - timeStepIdx); + return this->schedule()[timeStepIdx] + .wellgroup_events().hasEvent(this->wells_ecl_[well_index].name(), + ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX); }; auto getWellPI = [this](const int well_index) -> double diff --git a/opm/simulators/wells/WellGroupHelpers.cpp b/opm/simulators/wells/WellGroupHelpers.cpp index 0029a5e99..417abb4e5 100644 --- a/opm/simulators/wells/WellGroupHelpers.cpp +++ b/opm/simulators/wells/WellGroupHelpers.cpp @@ -79,8 +79,9 @@ namespace WellGroupHelpers wellState.setCurrentProductionGroupControl(group.name(), Group::ProductionCMode::NONE); } + const auto& events = schedule[reportStepIdx].wellgroup_events(); if (group.isInjectionGroup() - && schedule.hasWellGroupEvent(group.name(), ScheduleEvents::GROUP_INJECTION_UPDATE, reportStepIdx)) { + && events.hasEvent(group.name(), ScheduleEvents::GROUP_INJECTION_UPDATE)) { for (Phase phase : all) { if (!group.hasInjectionControl(phase)) @@ -92,7 +93,7 @@ namespace WellGroupHelpers } if (group.isProductionGroup() - && schedule.hasWellGroupEvent(group.name(), ScheduleEvents::GROUP_PRODUCTION_UPDATE, reportStepIdx)) { + && events.hasEvent(group.name(), ScheduleEvents::GROUP_PRODUCTION_UPDATE)) { const auto controls = group.productionControls(summaryState); wellState.setCurrentProductionGroupControl(group.name(), controls.cmode); } diff --git a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp index 761b2fc42..cb5590cae 100644 --- a/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp +++ b/opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp @@ -121,7 +121,7 @@ namespace Opm + ScheduleEvents::INJECTION_UPDATE; for (int w = 0; w < nw; ++w) { effective_events_occurred_[w] - = schedule.hasWellGroupEvent(wells_ecl[w].name(), effective_events_mask, report_step); + = schedule[report_step].wellgroup_events().hasEvent(wells_ecl[w].name(), effective_events_mask); } } // end of if (!well_ecl.empty() )