Assemble UDQState external to the vanguard

This commit is contained in:
Joakim Hove
2021-07-01 08:24:59 +02:00
parent d5658e39db
commit 528078e8e1
5 changed files with 25 additions and 6 deletions

View File

@@ -60,6 +60,7 @@ bool EclGenericVanguard::externalDeckSet_ = false;
std::unique_ptr<EclipseState> EclGenericVanguard::externalEclState_; 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_;
EclGenericVanguard::EclGenericVanguard() EclGenericVanguard::EclGenericVanguard()
: python(std::make_shared<Python>()) : python(std::make_shared<Python>())
@@ -99,6 +100,11 @@ void EclGenericVanguard::setExternalEclState(std::unique_ptr<EclipseState> eclSt
externalEclState_ = std::move(eclState); externalEclState_ = std::move(eclState);
} }
void EclGenericVanguard::setExternalUDQState(std::unique_ptr<UDQState> udqState)
{
externalUDQState_ = std::move(udqState);
}
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
@@ -259,14 +265,17 @@ void EclGenericVanguard::init()
parseContext_ = createParseContext(ignoredKeywords_, eclStrictParsing_); parseContext_ = createParseContext(ignoredKeywords_, eclStrictParsing_);
} }
readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, udqState_,
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_);
if (EclGenericVanguard::externalUDQState_)
this->udqState_ = std::move(EclGenericVanguard::externalUDQState_);
else
this->udqState_ = std::make_unique<UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() );
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->udqState_ = std::make_unique<UDQState>( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() ); this->actionState_ = std::make_unique<Action::State>();
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

@@ -141,6 +141,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);
/*! /*!
* \brief Return a reference to the parsed ECL deck. * \brief Return a reference to the parsed ECL deck.
*/ */
@@ -277,6 +278,8 @@ protected:
static std::unique_ptr<EclipseState> externalEclState_; static std::unique_ptr<EclipseState> externalEclState_;
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_;
std::string caseName_; std::string caseName_;
std::string fileName_; std::string fileName_;

View File

@@ -46,6 +46,7 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp> #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#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/models/utils/propertysystem.hh> #include <opm/models/utils/propertysystem.hh>
#include <opm/models/utils/parametersystem.hh> #include <opm/models/utils/parametersystem.hh>
@@ -461,7 +462,7 @@ namespace Opm
if (output_param >= 0) if (output_param >= 0)
outputInterval = output_param; outputInterval = output_param;
readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, udqState_,
summaryConfig_, nullptr, python, std::move(parseContext), summaryConfig_, nullptr, python, std::move(parseContext),
init_from_restart_file, outputCout_, outputInterval); init_from_restart_file, outputCout_, outputInterval);
@@ -542,6 +543,7 @@ namespace Opm
std::unique_ptr<Deck> deck_; std::unique_ptr<Deck> deck_;
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<SummaryConfig> summaryConfig_; std::unique_ptr<SummaryConfig> summaryConfig_;
}; };

View File

@@ -46,6 +46,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#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/Parser/Parser.hpp> #include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp> #include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@@ -186,7 +187,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<Opm::SummaryConfig>& summaryConfig, std::unique_ptr<Opm::Schedule>& schedule, std::unique_ptr<UDQState>& udqState, 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)
{ {
@@ -243,11 +244,14 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& d
const auto rst_state = Opm::RestartIO::RstState::load(std::move(rst_view)); const auto rst_state = Opm::RestartIO::RstState::load(std::move(rst_view));
if (!schedule) if (!schedule)
schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python, outputInterval, &rst_state); schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python, outputInterval, &rst_state);
udqState = std::make_unique<Opm::UDQState>( schedule->operator[](0).udq().params().undefinedValue() );
} }
else { else {
if (!schedule) if (!schedule)
schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python); schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python);
udqState = std::make_unique<Opm::UDQState>( schedule->operator[](0).udq().params().undefinedValue() );
} }
if (Opm::OpmLog::hasBackend("STDOUT_LOGGER")) // loggers might not be set up! if (Opm::OpmLog::hasBackend("STDOUT_LOGGER")) // loggers might not be set up!
{ {
setupMessageLimiter(schedule->operator[](0).message_limits(), "STDOUT_LOGGER"); setupMessageLimiter(schedule->operator[](0).message_limits(), "STDOUT_LOGGER");

View File

@@ -36,6 +36,7 @@ class ParseContext;
class Python; class Python;
class Schedule; class Schedule;
class SummaryConfig; class SummaryConfig;
class UDQState;
enum class FileOutputMode { enum class FileOutputMode {
//! \brief No output to files. //! \brief No output to files.
@@ -53,7 +54,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<SummaryConfig>& summaryConfig, std::unique_ptr<Schedule>& schedule, std::unique_ptr<UDQState>& udqState, 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