mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-13 15:55:36 -06:00
Merge pull request #2674 from joakim-hove/use-action-state
Add Action::State member to EclPropblem and pass it to io/ActionX
This commit is contained in:
commit
d89a2e5eb7
ebos
opm/simulators/utils
tests
@ -47,6 +47,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
|
||||
|
||||
#if HAVE_MPI
|
||||
@ -351,6 +352,7 @@ public:
|
||||
else
|
||||
eclSchedule_ = externalEclSchedule_;
|
||||
this->summaryState_.reset( new Opm::SummaryState( std::chrono::system_clock::from_time_t(this->eclSchedule_->getStartTime() )));
|
||||
this->actionState_.reset( new Opm::Action::State() );
|
||||
|
||||
if (!externalEclSummaryConfig_) {
|
||||
// create the schedule object. Note that if eclState is supposed to represent
|
||||
@ -447,6 +449,18 @@ public:
|
||||
const Opm::SummaryState& summaryState() const
|
||||
{ return *summaryState_; }
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Returns the action state
|
||||
*
|
||||
* The ActionState keeps track of how many times the various actions have run.
|
||||
*/
|
||||
Opm::Action::State& actionState()
|
||||
{ return *actionState_; }
|
||||
|
||||
const Opm::Action::State& actionState() const
|
||||
{ return *actionState_; }
|
||||
|
||||
/*!
|
||||
* \brief Parameter deciding the edge-weight strategy of the load balancer.
|
||||
*/
|
||||
@ -617,6 +631,7 @@ private:
|
||||
std::unique_ptr<Opm::Schedule> internalEclSchedule_;
|
||||
std::unique_ptr<Opm::SummaryConfig> internalEclSummaryConfig_;
|
||||
std::unique_ptr<Opm::SummaryState> summaryState_;
|
||||
std::unique_ptr<Opm::Action::State> actionState_;
|
||||
|
||||
// these attributes point either to the internal or to the external version of the
|
||||
// parser objects.
|
||||
|
@ -997,6 +997,7 @@ public:
|
||||
simulator.time() + simulator.timeStepSize(),
|
||||
ecl_state,
|
||||
schedule,
|
||||
simulator.vanguard().actionState(),
|
||||
simulator.vanguard().summaryState());
|
||||
}
|
||||
|
||||
@ -1062,6 +1063,7 @@ public:
|
||||
double sim_time,
|
||||
Opm::EclipseState& ecl_state,
|
||||
Opm::Schedule& schedule,
|
||||
Opm::Action::State& actionState,
|
||||
Opm::SummaryState& summaryState) {
|
||||
const auto& actions = schedule.actions(reportStep);
|
||||
if (actions.empty())
|
||||
@ -1084,8 +1086,8 @@ public:
|
||||
}
|
||||
|
||||
auto simTime = schedule.simTime(reportStep);
|
||||
for (const auto& action : actions.pending(simTime)) {
|
||||
auto actionResult = action->eval(simTime, context);
|
||||
for (const auto& action : actions.pending(actionState, simTime)) {
|
||||
auto actionResult = action->eval(context);
|
||||
if (actionResult) {
|
||||
std::string wells_string;
|
||||
const auto& matching_wells = actionResult.wells();
|
||||
@ -1097,6 +1099,7 @@ public:
|
||||
std::string msg = "The action: " + action->name() + " evaluated to true at " + ts + " wells: " + wells_string;
|
||||
Opm::OpmLog::info(msg);
|
||||
schedule.applyAction(reportStep, *action, actionResult);
|
||||
actionState.add_run(*action, simTime);
|
||||
} else {
|
||||
std::string msg = "The action: " + action->name() + " evaluated to false at " + ts;
|
||||
Opm::OpmLog::info(msg);
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/eclipse/Summary.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
|
||||
#include <opm/simulators/utils/ParallelRestart.hpp>
|
||||
#include <opm/grid/GridHelpers.hpp>
|
||||
@ -395,7 +396,8 @@ public:
|
||||
restartValue.addExtra("OPMEXTRA", std::vector<double>(1, nextStepSize));
|
||||
|
||||
// first, create a tasklet to write the data for the current time step to disk
|
||||
auto eclWriteTasklet = std::make_shared<EclWriteTasklet>(summaryState(),
|
||||
auto eclWriteTasklet = std::make_shared<EclWriteTasklet>(actionState(),
|
||||
summaryState(),
|
||||
*eclIO_,
|
||||
reportStepNum,
|
||||
isSubStep,
|
||||
@ -449,7 +451,8 @@ public:
|
||||
|
||||
{
|
||||
Opm::SummaryState& summaryState = simulator_.vanguard().summaryState();
|
||||
auto restartValues = loadParallelRestart(eclIO_.get(), summaryState, solutionKeys, extraKeys,
|
||||
Opm::Action::State& actionState = simulator_.vanguard().actionState();
|
||||
auto restartValues = loadParallelRestart(eclIO_.get(), actionState, summaryState, solutionKeys, extraKeys,
|
||||
gridView.grid().comm());
|
||||
|
||||
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
|
||||
@ -688,6 +691,7 @@ private:
|
||||
struct EclWriteTasklet
|
||||
: public TaskletInterface
|
||||
{
|
||||
Opm::Action::State actionState_;
|
||||
Opm::SummaryState summaryState_;
|
||||
Opm::EclipseIO& eclIO_;
|
||||
int reportStepNum_;
|
||||
@ -696,14 +700,16 @@ private:
|
||||
Opm::RestartValue restartValue_;
|
||||
bool writeDoublePrecision_;
|
||||
|
||||
explicit EclWriteTasklet(const Opm::SummaryState& summaryState,
|
||||
explicit EclWriteTasklet(const Opm::Action::State& actionState,
|
||||
const Opm::SummaryState& summaryState,
|
||||
Opm::EclipseIO& eclIO,
|
||||
int reportStepNum,
|
||||
bool isSubStep,
|
||||
double secondsElapsed,
|
||||
Opm::RestartValue restartValue,
|
||||
bool writeDoublePrecision)
|
||||
: summaryState_(summaryState)
|
||||
: actionState_(actionState)
|
||||
, summaryState_(summaryState)
|
||||
, eclIO_(eclIO)
|
||||
, reportStepNum_(reportStepNum)
|
||||
, isSubStep_(isSubStep)
|
||||
@ -715,7 +721,8 @@ private:
|
||||
// callback to eclIO serial writeTimeStep method
|
||||
void run()
|
||||
{
|
||||
eclIO_.writeTimeStep(summaryState_,
|
||||
eclIO_.writeTimeStep(actionState_,
|
||||
summaryState_,
|
||||
reportStepNum_,
|
||||
isSubStep_,
|
||||
secondsElapsed_,
|
||||
@ -730,6 +737,9 @@ private:
|
||||
Opm::SummaryState& summaryState()
|
||||
{ return simulator_.vanguard().summaryState(); }
|
||||
|
||||
Opm::Action::State& actionState()
|
||||
{ return simulator_.vanguard().actionState(); }
|
||||
|
||||
const Opm::Schedule& schedule() const
|
||||
{ return simulator_.vanguard().schedule(); }
|
||||
|
||||
|
@ -818,7 +818,7 @@ INSTANTIATE_PACK(std::set<std::string>)
|
||||
|
||||
} // end namespace Mpi
|
||||
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, Action::State& actionState, SummaryState& summaryState,
|
||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||
const std::vector<Opm::RestartKey>& extraKeys,
|
||||
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> comm)
|
||||
@ -831,7 +831,7 @@ RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summarySt
|
||||
if (eclIO)
|
||||
{
|
||||
assert(comm.rank() == 0);
|
||||
restartValues = eclIO->loadRestart(summaryState, solutionKeys, extraKeys);
|
||||
restartValues = eclIO->loadRestart(actionState, summaryState, solutionKeys, extraKeys);
|
||||
int packedSize = Mpi::packSize(restartValues, comm);
|
||||
std::vector<char> buffer(packedSize);
|
||||
int position=0;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
#include <opm/output/eclipse/Summary.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
|
||||
@ -313,7 +314,7 @@ ADD_PACK_PROTOTYPES(std::string)
|
||||
|
||||
} // end namespace Mpi
|
||||
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, SummaryState& summaryState,
|
||||
RestartValue loadParallelRestart(const EclipseIO* eclIO, Action::State& actionState, SummaryState& summaryState,
|
||||
const std::vector<Opm::RestartKey>& solutionKeys,
|
||||
const std::vector<Opm::RestartKey>& extraKeys,
|
||||
Dune::CollectiveCommunication<Dune::MPIHelper::MPICommunicator> comm);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <ebos/collecttoiorank.hh>
|
||||
#include <ebos/ecloutputblackoilmodule.hh>
|
||||
#include <ebos/eclwriter.hh>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
|
||||
#if HAVE_DUNE_FEM
|
||||
#include <dune/fem/misc/mpimanager.hh>
|
||||
|
Loading…
Reference in New Issue
Block a user