Create Action::State external to the vanguard

This commit is contained in:
Joakim Hove
2021-09-19 10:17:58 +02:00
parent 7b833b7706
commit 357540bfca
6 changed files with 28 additions and 5 deletions

View File

@@ -61,6 +61,7 @@ std::unique_ptr<EclipseState> EclGenericVanguard::externalEclState_;
std::unique_ptr<Schedule> EclGenericVanguard::externalEclSchedule_; std::unique_ptr<Schedule> EclGenericVanguard::externalEclSchedule_;
std::unique_ptr<SummaryConfig> EclGenericVanguard::externalEclSummaryConfig_; std::unique_ptr<SummaryConfig> EclGenericVanguard::externalEclSummaryConfig_;
std::unique_ptr<UDQState> EclGenericVanguard::externalUDQState_; std::unique_ptr<UDQState> EclGenericVanguard::externalUDQState_;
std::unique_ptr<Action::State> EclGenericVanguard::externalActionState_;
std::unique_ptr<EclGenericVanguard::CommunicationType> EclGenericVanguard::comm_; std::unique_ptr<EclGenericVanguard::CommunicationType> EclGenericVanguard::comm_;
EclGenericVanguard::EclGenericVanguard() EclGenericVanguard::EclGenericVanguard()
@@ -106,6 +107,11 @@ void EclGenericVanguard::setExternalUDQState(std::unique_ptr<UDQState> udqState)
externalUDQState_ = std::move(udqState); externalUDQState_ = std::move(udqState);
} }
void EclGenericVanguard::setExternalActionState(std::unique_ptr<Action::State> actionState)
{
externalActionState_ = std::move(actionState);
}
std::string EclGenericVanguard::canonicalDeckPath(const std::string& caseName) std::string EclGenericVanguard::canonicalDeckPath(const std::string& caseName)
{ {
const auto fileExists = [](const filesystem::path& f) -> bool const auto fileExists = [](const filesystem::path& f) -> bool
@@ -266,7 +272,7 @@ void EclGenericVanguard::init()
parseContext_ = createParseContext(ignoredKeywords_, eclStrictParsing_); parseContext_ = createParseContext(ignoredKeywords_, eclStrictParsing_);
} }
readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, udqState_, readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, udqState_, actionState_,
eclSummaryConfig_, std::move(errorGuard), python, eclSummaryConfig_, std::move(errorGuard), python,
std::move(parseContext_), /* initFromRestart = */ false, std::move(parseContext_), /* initFromRestart = */ false,
/* checkDeck = */ enableExperiments_, outputInterval_); /* checkDeck = */ enableExperiments_, outputInterval_);
@@ -275,8 +281,13 @@ void EclGenericVanguard::init()
this->udqState_ = std::move(EclGenericVanguard::externalUDQState_); this->udqState_ = std::move(EclGenericVanguard::externalUDQState_);
else else
this->udqState_ = std::make_unique<UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() ); this->udqState_ = std::make_unique<UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() );
if (EclGenericVanguard::externalActionState_)
this->actionState_ = std::move(EclGenericVanguard::externalActionState_);
else
this->actionState_ = std::make_unique<Action::State>();
this->summaryState_ = std::make_unique<SummaryState>( TimeService::from_time_t(this->eclSchedule_->getStartTime() )); this->summaryState_ = std::make_unique<SummaryState>( TimeService::from_time_t(this->eclSchedule_->getStartTime() ));
this->actionState_ = std::make_unique<Action::State>();
// Initialize parallelWells with all local wells // Initialize parallelWells with all local wells
const auto& schedule_wells = schedule().getWellsatEnd(); const auto& schedule_wells = schedule().getWellsatEnd();

View File

@@ -153,6 +153,7 @@ public:
static void setExternalSummaryConfig(std::unique_ptr<SummaryConfig> summaryConfig); static void setExternalSummaryConfig(std::unique_ptr<SummaryConfig> summaryConfig);
static void setExternalUDQState(std::unique_ptr<UDQState> udqState); static void setExternalUDQState(std::unique_ptr<UDQState> udqState);
static void setExternalActionState(std::unique_ptr<Action::State> actionState);
/*! /*!
* \brief Return a reference to the parsed ECL deck. * \brief Return a reference to the parsed ECL deck.
*/ */
@@ -301,6 +302,7 @@ protected:
static std::unique_ptr<Schedule> externalEclSchedule_; static std::unique_ptr<Schedule> externalEclSchedule_;
static std::unique_ptr<SummaryConfig> externalEclSummaryConfig_; static std::unique_ptr<SummaryConfig> externalEclSummaryConfig_;
static std::unique_ptr<UDQState> externalUDQState_; static std::unique_ptr<UDQState> externalUDQState_;
static std::unique_ptr<Action::State> externalActionState_;
static std::unique_ptr<CommunicationType> comm_; static std::unique_ptr<CommunicationType> comm_;
std::string caseName_; std::string caseName_;

View File

@@ -47,6 +47,7 @@
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp> #include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/models/utils/propertysystem.hh> #include <opm/models/utils/propertysystem.hh>
#include <opm/models/utils/parametersystem.hh> #include <opm/models/utils/parametersystem.hh>
@@ -470,7 +471,7 @@ namespace Opm
if (output_param >= 0) if (output_param >= 0)
outputInterval = output_param; outputInterval = output_param;
readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, udqState_, readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, udqState_, actionState_,
summaryConfig_, nullptr, python, std::move(parseContext), summaryConfig_, nullptr, python, std::move(parseContext),
init_from_restart_file, outputCout_, outputInterval); init_from_restart_file, outputCout_, outputInterval);
@@ -552,6 +553,7 @@ namespace Opm
std::unique_ptr<EclipseState> eclipseState_; std::unique_ptr<EclipseState> eclipseState_;
std::unique_ptr<Schedule> schedule_; std::unique_ptr<Schedule> schedule_;
std::unique_ptr<UDQState> udqState_; std::unique_ptr<UDQState> udqState_;
std::unique_ptr<Action::State> actionState_;
std::unique_ptr<SummaryConfig> summaryConfig_; std::unique_ptr<SummaryConfig> summaryConfig_;
}; };

View File

@@ -48,6 +48,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp> #include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp> #include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp> #include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@@ -191,7 +192,7 @@ void setupMessageLimiter(const Opm::MessageLimits msgLimits, const std::string&
void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& deck, std::unique_ptr<Opm::EclipseState>& eclipseState, void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& deck, std::unique_ptr<Opm::EclipseState>& eclipseState,
std::unique_ptr<Opm::Schedule>& schedule, std::unique_ptr<UDQState>& udqState, std::unique_ptr<Opm::SummaryConfig>& summaryConfig, std::unique_ptr<Opm::Schedule>& schedule, std::unique_ptr<UDQState>& udqState, std::unique_ptr<Action::State>& actionState, std::unique_ptr<Opm::SummaryConfig>& summaryConfig,
std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Opm::Python>& python, std::unique_ptr<ParseContext> parseContext, std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Opm::Python>& python, std::unique_ptr<ParseContext> parseContext,
bool initFromRestart, bool checkDeck, const std::optional<int>& outputInterval) bool initFromRestart, bool checkDeck, const std::optional<int>& outputInterval)
{ {
@@ -280,6 +281,7 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& d
udqState = std::make_unique<UDQState>((*schedule)[0].udq().params().undefinedValue()); udqState = std::make_unique<UDQState>((*schedule)[0].udq().params().undefinedValue());
udqState->load_rst(rst_state); udqState->load_rst(rst_state);
actionState = std::make_unique<Action::State>();
} }
else { else {
if (!schedule) { if (!schedule) {
@@ -289,6 +291,7 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& d
} }
udqState = std::make_unique<UDQState>((*schedule)[0].udq().params().undefinedValue()); udqState = std::make_unique<UDQState>((*schedule)[0].udq().params().undefinedValue());
actionState = std::make_unique<Action::State>();
} }

View File

@@ -38,6 +38,10 @@ class Schedule;
class SummaryConfig; class SummaryConfig;
class UDQState; class UDQState;
namespace Action {
class State;
}
enum class FileOutputMode { enum class FileOutputMode {
//! \brief No output to files. //! \brief No output to files.
OUTPUT_NONE = 0, OUTPUT_NONE = 0,
@@ -54,7 +58,7 @@ FileOutputMode setupLogging(int mpi_rank_, const std::string& deck_filename, con
/// ///
/// If pointers already contains objects then they are used otherwise they are created and can be used outside later. /// If pointers already contains objects then they are used otherwise they are created and can be used outside later.
void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Deck>& deck, std::unique_ptr<EclipseState>& eclipseState, void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Deck>& deck, std::unique_ptr<EclipseState>& eclipseState,
std::unique_ptr<Schedule>& schedule, std::unique_ptr<UDQState>& udqState, std::unique_ptr<SummaryConfig>& summaryConfig, std::unique_ptr<Schedule>& schedule, std::unique_ptr<UDQState>& udqState, std::unique_ptr<Action::State>& actionState, std::unique_ptr<SummaryConfig>& summaryConfig,
std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Python>& python, std::unique_ptr<ParseContext> parseContext, std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Python>& python, std::unique_ptr<ParseContext> parseContext,
bool initFromRestart, bool checkDeck, const std::optional<int>& outputInterval); bool initFromRestart, bool checkDeck, const std::optional<int>& outputInterval);
} // end namespace Opm } // end namespace Opm

View File

@@ -37,4 +37,5 @@ then
${COMPARE_ECL_COMMAND} ${ignore_extra_kw} -a ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${FILENAME} ${RESULT_PATH}/${FILENAME} ${ABS_TOL} ${REL_TOL} ${COMPARE_ECL_COMMAND} ${ignore_extra_kw} -a ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${FILENAME} ${RESULT_PATH}/${FILENAME} ${ABS_TOL} ${REL_TOL}
fi fi
echo ">>> ${COMPARE_ECL_COMMAND} ${ignore_extra_kw} ${INPUT_DATA_PATH}/opm-simulation-reference/${EXE_NAME}/${FILENAME} ${RESULT_PATH}/${FILENAME} ${ABS_TOL} ${REL_TOL}"
exit $ecode exit $ecode