diff --git a/ebos/eclproblem.hh b/ebos/eclproblem.hh index fde2bf8bb..1e06ec216 100644 --- a/ebos/eclproblem.hh +++ b/ebos/eclproblem.hh @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -966,10 +967,13 @@ public: void endEpisode() { auto& simulator = this->simulator(); - const auto& schedule = simulator.vanguard().schedule(); + auto& schedule = simulator.vanguard().schedule(); const auto& timeMap = schedule.getTimeMap(); int episodeIdx = simulator.episodeIndex(); + this->applyActions(episodeIdx + 1, + schedule, + simulator.vanguard().summaryState()); // check if we're finished ... if (episodeIdx + 1 >= static_cast(timeMap.numTimesteps())) { @@ -1013,6 +1017,31 @@ public: eclWriter_->writeOutput(isSubStep); } + + void applyActions(int reportStep, + Opm::Schedule& schedule, + const Opm::SummaryState& summaryState) { + const auto& actions = schedule.actions(); + if (actions.empty()) + return; + + Opm::Action::Context context( summaryState ); + + auto simTime = schedule.simTime(reportStep); + for (const auto& action : actions.pending(simTime)) { + auto actionResult = action->eval(simTime, context); + if (actionResult) { + std::string msg = "The action: " + action->name() + " evaluated to true at report step: " + std::to_string(reportStep); + Opm::OpmLog::info(msg); + schedule.applyAction(reportStep, *action, actionResult); + } else { + std::string msg = "The action: " + action->name() + " evaluated to false sat report step: " + std::to_string(reportStep); + Opm::OpmLog::info(msg); + } + } + } + + /*! * \copydoc FvBaseMultiPhaseProblem::intrinsicPermeability */