Merge pull request #3010 from joakim-hove/sched-events

Fetch events from ScheduleState
This commit is contained in:
Joakim Hove
2021-01-11 20:24:31 +01:00
committed by GitHub
6 changed files with 29 additions and 31 deletions

View File

@@ -1019,18 +1019,18 @@ public:
int episodeIdx = simulator.episodeIndex(); int episodeIdx = simulator.episodeIndex();
auto& eclState = simulator.vanguard().eclState(); auto& eclState = simulator.vanguard().eclState();
const auto& schedule = simulator.vanguard().schedule(); const auto& schedule = simulator.vanguard().schedule();
const auto& events = schedule.getEvents(); const auto& events = schedule[episodeIdx].events();
const auto& timeMap = schedule.getTimeMap(); 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 // bring the contents of the keywords to the current state of the SCHEDULE
// section. // section.
// //
// TODO (?): make grid topology changes possible (depending on what exactly // TODO (?): make grid topology changes possible (depending on what exactly
// has changed, the grid may need be re-created which has some serious // has changed, the grid may need be re-created which has some serious
// implications on e.g., the solution of the simulation.) // implications on e.g., the solution of the simulation.)
const auto& miniDeck = schedule.getModifierDeck(episodeIdx); const auto& miniDeck = schedule[episodeIdx].geo_keywords();
eclState.applyModifierDeck(miniDeck); eclState.apply_geo_keywords( miniDeck );
// re-compute all quantities which may possibly be affected. // re-compute all quantities which may possibly be affected.
transmissibilities_.update(true); transmissibilities_.update(true);
@@ -1058,7 +1058,7 @@ public:
// react to TUNING changes // react to TUNING changes
bool tuningEvent = false; 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(); const auto& tuning = schedule[episodeIdx].tuning();
initialTimeStepSize_ = tuning.TSINIT; initialTimeStepSize_ = tuning.TSINIT;
@@ -3243,7 +3243,6 @@ private:
return dtNext; return dtNext;
const auto& simulator = this->simulator(); const auto& simulator = this->simulator();
const auto& events = simulator.vanguard().schedule().getEvents();
int episodeIdx = simulator.episodeIndex(); int episodeIdx = simulator.episodeIndex();
// first thing in the morning, limit the time step size to the maximum size // 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 // if a well event occured, respect the limit for the maximum time step after
// that, too // that, too
int reportStepIdx = std::max(episodeIdx, 0); int reportStepIdx = std::max(episodeIdx, 0);
const auto& events = simulator.vanguard().schedule()[reportStepIdx].events();
bool wellEventOccured = bool wellEventOccured =
events.hasEvent(Opm::ScheduleEvents::NEW_WELL, reportStepIdx) events.hasEvent(Opm::ScheduleEvents::NEW_WELL)
|| events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE, reportStepIdx) || events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE)
|| events.hasEvent(Opm::ScheduleEvents::INJECTION_UPDATE, reportStepIdx) || events.hasEvent(Opm::ScheduleEvents::INJECTION_UPDATE)
|| events.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE, reportStepIdx); || events.hasEvent(Opm::ScheduleEvents::WELL_STATUS_CHANGE);
if (episodeIdx >= 0 && wellEventOccured && maxTimeStepAfterWellEvent_ > 0) if (episodeIdx >= 0 && wellEventOccured && maxTimeStepAfterWellEvent_ > 0)
dtNext = std::min(dtNext, maxTimeStepAfterWellEvent_); dtNext = std::min(dtNext, maxTimeStepAfterWellEvent_);
} }

View File

@@ -609,11 +609,10 @@ public:
// for the "until the universe dies" episode, the wells don't change // for the "until the universe dies" episode, the wells don't change
return false; return false;
const Opm::Events& events = schedule.getEvents(); const Opm::Events& events = schedule[reportStepIdx].events();
return events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE | return events.hasEvent(Opm::ScheduleEvents::PRODUCTION_UPDATE |
Opm::ScheduleEvents::INJECTION_UPDATE | Opm::ScheduleEvents::INJECTION_UPDATE |
Opm::ScheduleEvents::WELL_STATUS_CHANGE, Opm::ScheduleEvents::WELL_STATUS_CHANGE );
reportStepIdx);
} }
void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){ void initFromRestartFile(const RestartValue& restartValues OPM_UNUSED){
@@ -636,10 +635,9 @@ protected:
// for the "until the universe dies" episode, the wells don't change // for the "until the universe dies" episode, the wells don't change
return false; return false;
const Opm::Events& events = schedule.getEvents(); const Opm::Events& events = schedule[reportStepIdx].events();
return events.hasEvent(Opm::ScheduleEvents::NEW_WELL | return events.hasEvent(Opm::ScheduleEvents::NEW_WELL |
Opm::ScheduleEvents::COMPLETION_CHANGE, Opm::ScheduleEvents::COMPLETION_CHANGE);
reportStepIdx);
} }
void updateWellTopology_(unsigned reportStepIdx OPM_UNUSED, void updateWellTopology_(unsigned reportStepIdx OPM_UNUSED,

View File

@@ -235,7 +235,6 @@ public:
timer.currentStepLength()); timer.currentStepLength());
ebosSimulator_.setEpisodeIndex(timer.currentStepNum()); ebosSimulator_.setEpisodeIndex(timer.currentStepNum());
solver->model().beginReportStep(); solver->model().beginReportStep();
const auto& events = schedule().getEvents();
bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, EnableTuning); bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, EnableTuning);
// If sub stepping is enabled allow the solver to sub cycle // 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 report steps are met in any case
// \Note: The sub stepping will require a copy of the state variables // \Note: The sub stepping will require a copy of the state variables
if (adaptiveTimeStepping_) { if (adaptiveTimeStepping_) {
const auto& events = schedule()[timer.currentStepNum()].events();
if (enableTUNING) { if (enableTUNING) {
if (events.hasEvent(ScheduleEvents::TUNING_CHANGE,timer.currentStepNum())) { if (events.hasEvent(ScheduleEvents::TUNING_CHANGE)) {
adaptiveTimeStepping_->updateTUNING(schedule()[timer.currentStepNum()].tuning()); adaptiveTimeStepping_->updateTUNING(schedule()[timer.currentStepNum()].tuning());
} }
} }
bool event = events.hasEvent(ScheduleEvents::NEW_WELL, timer.currentStepNum()) || bool event = events.hasEvent(ScheduleEvents::NEW_WELL) ||
events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE, timer.currentStepNum()) || events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE) ||
events.hasEvent(ScheduleEvents::INJECTION_UPDATE, timer.currentStepNum()) || events.hasEvent(ScheduleEvents::INJECTION_UPDATE) ||
events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE, timer.currentStepNum()); events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE);
auto stepReport = adaptiveTimeStepping_->step(timer, *solver, event, nullptr); auto stepReport = adaptiveTimeStepping_->step(timer, *solver, event, nullptr);
report_ += stepReport; report_ += stepReport;
} else { } else {

View File

@@ -282,7 +282,7 @@ namespace Opm {
+ ScheduleEvents::INJECTION_UPDATE + ScheduleEvents::INJECTION_UPDATE
+ ScheduleEvents::NEW_WELL; + ScheduleEvents::NEW_WELL;
if(!schedule().hasWellGroupEvent(well.name(), effective_events_mask, timeStepIdx)) if(!schedule()[timeStepIdx].wellgroup_events().hasEvent(well.name(), effective_events_mask))
continue; continue;
if (well.isProducer()) { if (well.isProducer()) {
@@ -308,7 +308,7 @@ namespace Opm {
schedule().getVFPProdTables(timeStepIdx)) ); schedule().getVFPProdTables(timeStepIdx)) );
this->initializeWellProdIndCalculators(); 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); this->runWellPIScaling(timeStepIdx, local_deferredLogger);
} }
@@ -2628,10 +2628,9 @@ namespace Opm {
auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool auto hasWellPIEvent = [this, timeStepIdx](const int well_index) -> bool
{ {
return this->schedule() return this->schedule()[timeStepIdx]
.hasWellGroupEvent(this->wells_ecl_[well_index].name(), .wellgroup_events().hasEvent(this->wells_ecl_[well_index].name(),
ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX, ScheduleEvents::Events::WELL_PRODUCTIVITY_INDEX);
timeStepIdx);
}; };
auto getWellPI = [this](const int well_index) -> double auto getWellPI = [this](const int well_index) -> double

View File

@@ -79,8 +79,9 @@ namespace WellGroupHelpers
wellState.setCurrentProductionGroupControl(group.name(), Group::ProductionCMode::NONE); wellState.setCurrentProductionGroupControl(group.name(), Group::ProductionCMode::NONE);
} }
const auto& events = schedule[reportStepIdx].wellgroup_events();
if (group.isInjectionGroup() if (group.isInjectionGroup()
&& schedule.hasWellGroupEvent(group.name(), ScheduleEvents::GROUP_INJECTION_UPDATE, reportStepIdx)) { && events.hasEvent(group.name(), ScheduleEvents::GROUP_INJECTION_UPDATE)) {
for (Phase phase : all) { for (Phase phase : all) {
if (!group.hasInjectionControl(phase)) if (!group.hasInjectionControl(phase))
@@ -92,7 +93,7 @@ namespace WellGroupHelpers
} }
if (group.isProductionGroup() 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); const auto controls = group.productionControls(summaryState);
wellState.setCurrentProductionGroupControl(group.name(), controls.cmode); wellState.setCurrentProductionGroupControl(group.name(), controls.cmode);
} }

View File

@@ -121,7 +121,7 @@ namespace Opm
+ ScheduleEvents::INJECTION_UPDATE; + ScheduleEvents::INJECTION_UPDATE;
for (int w = 0; w < nw; ++w) { for (int w = 0; w < nw; ++w) {
effective_events_occurred_[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() ) } // end of if (!well_ecl.empty() )