diff --git a/ebos/eclgenericvanguard.cc b/ebos/eclgenericvanguard.cc index a2700e495..691cdd02c 100644 --- a/ebos/eclgenericvanguard.cc +++ b/ebos/eclgenericvanguard.cc @@ -60,6 +60,7 @@ bool EclGenericVanguard::externalDeckSet_ = false; std::unique_ptr EclGenericVanguard::externalEclState_; std::unique_ptr EclGenericVanguard::externalEclSchedule_; std::unique_ptr EclGenericVanguard::externalEclSummaryConfig_; +std::unique_ptr EclGenericVanguard::externalUDQState_; EclGenericVanguard::EclGenericVanguard() : python(std::make_shared()) @@ -99,6 +100,11 @@ void EclGenericVanguard::setExternalEclState(std::unique_ptr eclSt externalEclState_ = std::move(eclState); } +void EclGenericVanguard::setExternalUDQState(std::unique_ptr udqState) +{ + externalUDQState_ = std::move(udqState); +} + std::string EclGenericVanguard::canonicalDeckPath(const std::string& caseName) { const auto fileExists = [](const filesystem::path& f) -> bool @@ -259,14 +265,17 @@ void EclGenericVanguard::init() parseContext_ = createParseContext(ignoredKeywords_, eclStrictParsing_); } - readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, + readDeck(myRank, fileName_, deck_, eclState_, eclSchedule_, udqState_, eclSummaryConfig_, std::move(errorGuard), python, std::move(parseContext_), /* initFromRestart = */ false, /* checkDeck = */ enableExperiments_, outputInterval_); + if (EclGenericVanguard::externalUDQState_) + this->udqState_ = std::move(EclGenericVanguard::externalUDQState_); + else + this->udqState_ = std::make_unique( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() ); this->summaryState_ = std::make_unique( TimeService::from_time_t(this->eclSchedule_->getStartTime() )); - this->udqState_ = std::make_unique( this->eclSchedule_->getUDQConfig(0).params().undefinedValue() ); - this->actionState_ = std::make_unique() ; + this->actionState_ = std::make_unique(); // Initialize parallelWells with all local wells const auto& schedule_wells = schedule().getWellsatEnd(); diff --git a/ebos/eclgenericvanguard.hh b/ebos/eclgenericvanguard.hh index f023db284..af66e4c11 100644 --- a/ebos/eclgenericvanguard.hh +++ b/ebos/eclgenericvanguard.hh @@ -141,6 +141,7 @@ public: */ static void setExternalSummaryConfig(std::unique_ptr summaryConfig); + static void setExternalUDQState(std::unique_ptr udqState); /*! * \brief Return a reference to the parsed ECL deck. */ @@ -277,6 +278,8 @@ protected: static std::unique_ptr externalEclState_; static std::unique_ptr externalEclSchedule_; static std::unique_ptr externalEclSummaryConfig_; + static std::unique_ptr externalUDQState_; + std::string caseName_; std::string fileName_; diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 3706b050d..e97bd1763 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -461,7 +462,7 @@ namespace Opm if (output_param >= 0) outputInterval = output_param; - readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, + readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_, udqState_, summaryConfig_, nullptr, python, std::move(parseContext), init_from_restart_file, outputCout_, outputInterval); @@ -542,6 +543,7 @@ namespace Opm std::unique_ptr deck_; std::unique_ptr eclipseState_; std::unique_ptr schedule_; + std::unique_ptr udqState_; std::unique_ptr summaryConfig_; }; diff --git a/opm/simulators/utils/readDeck.cpp b/opm/simulators/utils/readDeck.cpp index 2b188cc08..884f21f13 100644 --- a/opm/simulators/utils/readDeck.cpp +++ b/opm/simulators/utils/readDeck.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -186,7 +187,7 @@ void setupMessageLimiter(const Opm::MessageLimits msgLimits, const std::string& void readDeck(int rank, std::string& deckFilename, std::unique_ptr& deck, std::unique_ptr& eclipseState, - std::unique_ptr& schedule, std::unique_ptr& summaryConfig, + std::unique_ptr& schedule, std::unique_ptr& udqState, std::unique_ptr& summaryConfig, std::unique_ptr errorGuard, std::shared_ptr& python, std::unique_ptr parseContext, bool initFromRestart, bool checkDeck, const std::optional& outputInterval) { @@ -243,11 +244,14 @@ void readDeck(int rank, std::string& deckFilename, std::unique_ptr& d const auto rst_state = Opm::RestartIO::RstState::load(std::move(rst_view)); if (!schedule) schedule = std::make_unique(*deck, *eclipseState, *parseContext, *errorGuard, python, outputInterval, &rst_state); + udqState = std::make_unique( schedule->operator[](0).udq().params().undefinedValue() ); } else { if (!schedule) schedule = std::make_unique(*deck, *eclipseState, *parseContext, *errorGuard, python); + udqState = std::make_unique( schedule->operator[](0).udq().params().undefinedValue() ); } + if (Opm::OpmLog::hasBackend("STDOUT_LOGGER")) // loggers might not be set up! { setupMessageLimiter(schedule->operator[](0).message_limits(), "STDOUT_LOGGER"); diff --git a/opm/simulators/utils/readDeck.hpp b/opm/simulators/utils/readDeck.hpp index 7d29f8e48..01d0aea00 100644 --- a/opm/simulators/utils/readDeck.hpp +++ b/opm/simulators/utils/readDeck.hpp @@ -36,6 +36,7 @@ class ParseContext; class Python; class Schedule; class SummaryConfig; +class UDQState; enum class FileOutputMode { //! \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. void readDeck(int rank, std::string& deckFilename, std::unique_ptr& deck, std::unique_ptr& eclipseState, - std::unique_ptr& schedule, std::unique_ptr& summaryConfig, + std::unique_ptr& schedule, std::unique_ptr& udqState, std::unique_ptr& summaryConfig, std::unique_ptr errorGuard, std::shared_ptr& python, std::unique_ptr parseContext, bool initFromRestart, bool checkDeck, const std::optional& outputInterval); } // end namespace Opm