diff --git a/flow/flow_ebos_blackoil.cpp b/flow/flow_ebos_blackoil.cpp index 809610682..e02595ba2 100644 --- a/flow/flow_ebos_blackoil.cpp +++ b/flow/flow_ebos_blackoil.cpp @@ -46,8 +46,8 @@ void flowEbosBlackoilSetDeck(double setupTime, Deck *deck, EclipseState& eclStat Vanguard::setExternalSummaryConfig(&summaryConfig); } -// ----------------- Main program ----------------- -int flowEbosBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles) +std::unique_ptr> +flowEbosBlackoilMainInit(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. @@ -59,8 +59,14 @@ int flowEbosBlackoilMain(int argc, char** argv, bool outputCout, bool outputFile Dune::MPIHelper::instance(argc, argv); #endif - Opm::FlowMainEbos mainfunc; - return mainfunc.execute(argc, argv, outputCout, outputFiles); + return std::make_unique>(); +} + +// ----------------- Main program ----------------- +int flowEbosBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles) +{ + auto mainfunc = flowEbosBlackoilMainInit(argc, argv, outputCout, outputFiles); + return mainfunc->execute(argc, argv, outputCout, outputFiles); } } diff --git a/flow/flow_ebos_blackoil.hpp b/flow/flow_ebos_blackoil.hpp index 641d74aa2..3ca378919 100644 --- a/flow/flow_ebos_blackoil.hpp +++ b/flow/flow_ebos_blackoil.hpp @@ -21,10 +21,15 @@ #include #include #include +#include namespace Opm { void flowEbosBlackoilSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig); + int flowEbosBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles); + +std::unique_ptr> + flowEbosBlackoilMainInit(int argc, char** argv, bool outputCout, bool outputFiles); } #endif // FLOW_EBOS_BLACKOIL_HPP diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index 10815af73..1e7814fc6 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -117,6 +117,7 @@ namespace Opm class Main { private: + using FlowMainEbosType = Opm::FlowMainEbos; enum class FileOutputMode { //! \brief No output to files. OUTPUT_NONE = 0, @@ -174,6 +175,30 @@ namespace Opm } } + // To be called from the Python interface code. Only do the + // initialization and then return a pointer to the FlowEbosMain + // object that can later be accessed directly from the Python interface + // to e.g. advance the simulator one report step + std::unique_ptr initFlowEbosBlackoil(int& exitCode) + { + exitCode = EXIT_SUCCESS; + if (initialize_(exitCode)) { + // TODO: check that this deck really represents a blackoil + // case. E.g. check that number of phases == 3 + Opm::flowEbosBlackoilSetDeck( + setupTime_, + deck_.get(), + *eclipseState_, + *schedule_, + *summaryConfig_); + return Opm::flowEbosBlackoilMainInit( + argc_, argv_, outputCout_, outputFiles_); + } else { + exitCode = EXIT_FAILURE; + return std::unique_ptr(); // nullptr + } + } + private: int dispatchDynamic_() {