Write vtk (if enabled) for dry runs

This commit is contained in:
David Landa Marban 2024-07-31 13:35:56 +02:00
parent ad595fed5e
commit d4890d18f7
5 changed files with 50 additions and 36 deletions

View File

@ -73,6 +73,10 @@ template<class TypeTag>
struct EclDeckFileName<TypeTag, Properties::TTag::FlowBaseVanguard> struct EclDeckFileName<TypeTag, Properties::TTag::FlowBaseVanguard>
{ static constexpr auto value = ""; }; { static constexpr auto value = ""; };
// TODO: enumeration parameters. we use strings for now.
template<class TypeTag, class MyTypeTag>
struct EnableDryRun { using type = Properties::UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EnableOpmRstFile { using type = Properties::UndefinedProperty; }; struct EnableOpmRstFile { using type = Properties::UndefinedProperty; };
@ -139,6 +143,11 @@ template<class TypeTag>
struct EclOutputInterval<TypeTag, Properties::TTag::FlowBaseVanguard> struct EclOutputInterval<TypeTag, Properties::TTag::FlowBaseVanguard>
{ static constexpr int value = -1; }; { static constexpr int value = -1; };
// TODO: enumeration parameters. we use strings for now.
template<class TypeTag>
struct EnableDryRun<TypeTag, Properties::TTag::FlowBaseVanguard>
{ static constexpr auto value = "auto"; };
template<class TypeTag> template<class TypeTag>
struct EnableOpmRstFile<TypeTag, Properties::TTag::FlowBaseVanguard> struct EnableOpmRstFile<TypeTag, Properties::TTag::FlowBaseVanguard>
{ static constexpr bool value = false; }; { static constexpr bool value = false; };
@ -242,6 +251,8 @@ public:
("The name of the file which contains the ECL deck to be simulated"); ("The name of the file which contains the ECL deck to be simulated");
Parameters::registerParam<TypeTag, Parameters::EclOutputInterval> Parameters::registerParam<TypeTag, Parameters::EclOutputInterval>
("The number of report steps that ought to be skipped between two writes of ECL results"); ("The number of report steps that ought to be skipped between two writes of ECL results");
Parameters::registerParam<TypeTag, Parameters::EnableDryRun>
("Specify if the simulation ought to be actually run, or just pretended to be");
Parameters::registerParam<TypeTag, Parameters::EnableOpmRstFile> Parameters::registerParam<TypeTag, Parameters::EnableOpmRstFile>
("Include OPM-specific keywords in the ECL restart file to " ("Include OPM-specific keywords in the ECL restart file to "
"enable restart of OPM simulators from these files"); "enable restart of OPM simulators from these files");
@ -543,6 +554,8 @@ protected:
std::string outputDir = Parameters::get<TypeTag, Parameters::OutputDir>(); std::string outputDir = Parameters::get<TypeTag, Parameters::OutputDir>();
bool enableEclCompatFile = !Parameters::get<TypeTag, Parameters::EnableOpmRstFile>(); bool enableEclCompatFile = !Parameters::get<TypeTag, Parameters::EnableOpmRstFile>();
asImp_().updateOutputDir_(outputDir, enableEclCompatFile); asImp_().updateOutputDir_(outputDir, enableEclCompatFile);
const std::string& dryRunString = Parameters::get<TypeTag, Parameters::EnableDryRun>();
asImp_().updateNOSIM_(dryRunString);
asImp_().finalizeInit_(); asImp_().finalizeInit_();
} }

View File

@ -175,6 +175,34 @@ std::string FlowGenericVanguard::canonicalDeckPath(const std::string& caseName)
throw std::invalid_argument("Cannot find input case '"+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, void FlowGenericVanguard::updateOutputDir_(std::string outputDir,
bool enableEclCompatFile) bool enableEclCompatFile)
{ {

View File

@ -284,6 +284,8 @@ protected:
void updateOutputDir_(std::string outputDir, void updateOutputDir_(std::string outputDir,
bool enableEclCompatFile); bool enableEclCompatFile);
void updateNOSIM_(std::string_view enableDryRun);
bool drsdtconEnabled() const; bool drsdtconEnabled() const;
std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const; std::unordered_map<std::size_t, const NumericalAquiferCell*> allAquiferCells() const;

View File

@ -44,20 +44,12 @@
namespace Opm::Parameters { namespace Opm::Parameters {
template<class TypeTag, class MyTypeTag>
struct EnableDryRun { using type = Properties::UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OutputInterval { using type = Properties::UndefinedProperty; }; struct OutputInterval { using type = Properties::UndefinedProperty; };
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct EnableLoggingFalloutWarning { using type = Properties::UndefinedProperty; }; struct EnableLoggingFalloutWarning { using type = Properties::UndefinedProperty; };
// TODO: enumeration parameters. we use strings for now.
template<class TypeTag>
struct EnableDryRun<TypeTag, Properties::TTag::FlowProblem>
{ static constexpr auto value = "auto"; };
// Do not merge parallel output files or warn about them // Do not merge parallel output files or warn about them
template<class TypeTag> template<class TypeTag>
struct EnableLoggingFalloutWarning<TypeTag, Properties::TTag::FlowProblem> struct EnableLoggingFalloutWarning<TypeTag, Properties::TTag::FlowProblem>
@ -110,8 +102,6 @@ namespace Opm {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// register the flow specific parameters // register the flow specific parameters
Parameters::registerParam<TypeTag, Parameters::EnableDryRun>
("Specify if the simulation ought to be actually run, or just pretended to be");
Parameters::registerParam<TypeTag, Parameters::OutputInterval> Parameters::registerParam<TypeTag, Parameters::OutputInterval>
("Specify the number of report steps between two consecutive writes of restart data"); ("Specify the number of report steps between two consecutive writes of restart data");
Parameters::registerParam<TypeTag, Parameters::EnableLoggingFalloutWarning> Parameters::registerParam<TypeTag, Parameters::EnableLoggingFalloutWarning>
@ -421,32 +411,6 @@ namespace Opm {
modelSimulator_ = std::make_unique<ModelSimulator>(FlowGenericVanguard::comm(), /*verbose=*/false); modelSimulator_ = std::make_unique<ModelSimulator>(FlowGenericVanguard::comm(), /*verbose=*/false);
modelSimulator_->executionTimer().start(); modelSimulator_->executionTimer().start();
modelSimulator_->model().applyInitialSolution(); modelSimulator_->model().applyInitialSolution();
try {
// Possible to force initialization only behavior (NOSIM).
const std::string& dryRunString = Parameters::get<TypeTag, Parameters::EnableDryRun>();
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 const EclipseState& eclState() const

View File

@ -314,6 +314,7 @@ public:
enableDriftCompensation_ = Parameters::get<TypeTag, Parameters::EnableDriftCompensation>(); enableDriftCompensation_ = Parameters::get<TypeTag, Parameters::EnableDriftCompensation>();
enableEclOutput_ = Parameters::get<TypeTag, Parameters::EnableEclOutput>(); enableEclOutput_ = Parameters::get<TypeTag, Parameters::EnableEclOutput>();
enableVtkOutput_ = Parameters::get<TypeTag, Parameters::EnableVtkOutput>();
this->enableTuning_ = Parameters::get<TypeTag, Parameters::EnableTuning>(); this->enableTuning_ = Parameters::get<TypeTag, Parameters::EnableTuning>();
this->initialTimeStepSize_ = Parameters::get<TypeTag, Parameters::InitialTimeStepSize>(); this->initialTimeStepSize_ = Parameters::get<TypeTag, Parameters::InitialTimeStepSize>();
@ -465,6 +466,11 @@ public:
drift_ = 0.0; 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 // after finishing the initialization and writing the initial solution, we move
// to the first "real" episode/report step // to the first "real" episode/report step
// for restart the episode index and start is already set // for restart the episode index and start is already set
@ -2839,6 +2845,7 @@ private:
AquiferModel aquiferModel_; AquiferModel aquiferModel_;
bool enableEclOutput_; bool enableEclOutput_;
bool enableVtkOutput_;
std::unique_ptr<EclWriterType> eclWriter_; std::unique_ptr<EclWriterType> eclWriter_;
#if HAVE_DAMARIS #if HAVE_DAMARIS