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