diff --git a/opm/simulators/flow/FlowBaseVanguard.hpp b/opm/simulators/flow/FlowBaseVanguard.hpp index 2376c505c..7e19fc66c 100644 --- a/opm/simulators/flow/FlowBaseVanguard.hpp +++ b/opm/simulators/flow/FlowBaseVanguard.hpp @@ -73,6 +73,10 @@ template struct EclDeckFileName { static constexpr auto value = ""; }; +// TODO: enumeration parameters. we use strings for now. +template +struct EnableDryRun { using type = Properties::UndefinedProperty; }; + template struct EnableOpmRstFile { using type = Properties::UndefinedProperty; }; @@ -139,6 +143,11 @@ template struct EclOutputInterval { static constexpr int value = -1; }; +// TODO: enumeration parameters. we use strings for now. +template +struct EnableDryRun +{ static constexpr auto value = "auto"; }; + template struct EnableOpmRstFile { static constexpr bool value = false; }; @@ -242,6 +251,8 @@ public: ("The name of the file which contains the ECL deck to be simulated"); Parameters::registerParam ("The number of report steps that ought to be skipped between two writes of ECL results"); + Parameters::registerParam + ("Specify if the simulation ought to be actually run, or just pretended to be"); Parameters::registerParam ("Include OPM-specific keywords in the ECL restart file to " "enable restart of OPM simulators from these files"); @@ -543,6 +554,8 @@ protected: std::string outputDir = Parameters::get(); bool enableEclCompatFile = !Parameters::get(); asImp_().updateOutputDir_(outputDir, enableEclCompatFile); + const std::string& dryRunString = Parameters::get(); + asImp_().updateNOSIM_(dryRunString); asImp_().finalizeInit_(); } diff --git a/opm/simulators/flow/FlowGenericVanguard.cpp b/opm/simulators/flow/FlowGenericVanguard.cpp index e5a27132d..23369e30f 100644 --- a/opm/simulators/flow/FlowGenericVanguard.cpp +++ b/opm/simulators/flow/FlowGenericVanguard.cpp @@ -175,6 +175,34 @@ std::string FlowGenericVanguard::canonicalDeckPath(const std::string& caseName) throw std::invalid_argument("Cannot find input case '"+caseName+"'"); } +void FlowGenericVanguard::updateNOSIM_(std::string_view dryRunString) +{ + try { + // Possible to force initialization only behavior (NOSIM). + if (dryRunString != "" && dryRunString != "auto") { + bool enableDryRun; + if (dryRunString == "true" + || dryRunString == "t" + || dryRunString == "1") + enableDryRun = true; + else if (dryRunString == "false" + || dryRunString == "f" + || dryRunString == "0") + enableDryRun = false; + else + throw std::invalid_argument("Invalid value for parameter EnableDryRun: '" + + std::string(dryRunString) + "'"); + auto& ioConfig = eclState().getIOConfig(); + ioConfig.overrideNOSIM(enableDryRun); + } + } + catch (const std::invalid_argument& e) { + std::cerr << "Failed to create valid EclipseState object" << std::endl; + std::cerr << "Exception caught: " << e.what() << std::endl; + throw; + } +} + void FlowGenericVanguard::updateOutputDir_(std::string outputDir, bool enableEclCompatFile) { diff --git a/opm/simulators/flow/FlowGenericVanguard.hpp b/opm/simulators/flow/FlowGenericVanguard.hpp index 9d6298876..bdad1db88 100644 --- a/opm/simulators/flow/FlowGenericVanguard.hpp +++ b/opm/simulators/flow/FlowGenericVanguard.hpp @@ -284,6 +284,8 @@ protected: void updateOutputDir_(std::string outputDir, bool enableEclCompatFile); + void updateNOSIM_(std::string_view enableDryRun); + bool drsdtconEnabled() const; std::unordered_map allAquiferCells() const; diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index 894922a6a..58f62e6ef 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -44,20 +44,12 @@ namespace Opm::Parameters { -template -struct EnableDryRun { using type = Properties::UndefinedProperty; }; - template struct OutputInterval { using type = Properties::UndefinedProperty; }; template struct EnableLoggingFalloutWarning { using type = Properties::UndefinedProperty; }; -// TODO: enumeration parameters. we use strings for now. -template -struct EnableDryRun -{ static constexpr auto value = "auto"; }; - // Do not merge parallel output files or warn about them template struct EnableLoggingFalloutWarning @@ -110,8 +102,6 @@ namespace Opm { return EXIT_SUCCESS; } // register the flow specific parameters - Parameters::registerParam - ("Specify if the simulation ought to be actually run, or just pretended to be"); Parameters::registerParam ("Specify the number of report steps between two consecutive writes of restart data"); Parameters::registerParam @@ -421,32 +411,6 @@ namespace Opm { modelSimulator_ = std::make_unique(FlowGenericVanguard::comm(), /*verbose=*/false); modelSimulator_->executionTimer().start(); modelSimulator_->model().applyInitialSolution(); - - try { - // Possible to force initialization only behavior (NOSIM). - const std::string& dryRunString = Parameters::get(); - if (dryRunString != "" && dryRunString != "auto") { - bool yesno; - if (dryRunString == "true" - || dryRunString == "t" - || dryRunString == "1") - yesno = true; - else if (dryRunString == "false" - || dryRunString == "f" - || dryRunString == "0") - yesno = false; - else - throw std::invalid_argument("Invalid value for parameter EnableDryRun: '" - +dryRunString+"'"); - auto& ioConfig = eclState().getIOConfig(); - ioConfig.overrideNOSIM(yesno); - } - } - catch (const std::invalid_argument& e) { - std::cerr << "Failed to create valid EclipseState object" << std::endl; - std::cerr << "Exception caught: " << e.what() << std::endl; - throw; - } } const EclipseState& eclState() const diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index f444b65ef..c4cc9479d 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -314,6 +314,7 @@ public: enableDriftCompensation_ = Parameters::get(); enableEclOutput_ = Parameters::get(); + enableVtkOutput_ = Parameters::get(); this->enableTuning_ = Parameters::get(); this->initialTimeStepSize_ = Parameters::get(); @@ -465,6 +466,11 @@ public: drift_ = 0.0; } + if (enableVtkOutput_ && eclState.getIOConfig().initOnly()) { + simulator.setTimeStepSize(0.0); + ParentType::writeOutput(true); + } + // after finishing the initialization and writing the initial solution, we move // to the first "real" episode/report step // for restart the episode index and start is already set @@ -2839,6 +2845,7 @@ private: AquiferModel aquiferModel_; bool enableEclOutput_; + bool enableVtkOutput_; std::unique_ptr eclWriter_; #if HAVE_DAMARIS