23#ifndef OPM_MAIN_HEADER_INCLUDED
24#define OPM_MAIN_HEADER_INCLUDED
26#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
27#include <opm/input/eclipse/Schedule/Action/State.hpp>
28#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
33#include <opm/simulators/flow/Banners.hpp>
34#include <opm/simulators/flow/FlowMain.hpp>
38#include <dune/fem/misc/mpimanager.hh>
40#include <dune/common/parallel/mpihelper.hh>
44#include <opm/simulators/utils/ParallelEclipseState.hpp>
48#include <opm/simulators/linalg/gpuistl/device_management.hpp>
52#include <opm/simulators/utils/DamarisKeywords.hpp>
67namespace Opm::Properties {
73 using InheritsFrom = std::tuple<FlowProblem>;
81namespace Action {
class State; }
86template <
class TypeTag>
87int flowMain(
int argc,
char** argv,
bool outputCout,
bool outputFiles)
93 FlowMain<TypeTag> mainfunc(argc, argv, outputCout, outputFiles);
94 return mainfunc.execute();
107 Main(
int argc,
char** argv,
bool ownMPI =
true);
110 explicit Main(
const std::string& filename,
bool mpi_init =
true,
bool mpi_finalize =
true);
114 Main(
const std::string& filename,
115 std::shared_ptr<EclipseState> eclipseState,
116 std::shared_ptr<Schedule> schedule,
117 std::shared_ptr<SummaryConfig> summaryConfig,
118 bool mpi_init =
true,
119 bool mpi_finalize =
true);
123 void setArgvArgc_(
const std::string& filename);
124 void maybeSaveReservoirCouplingSlaveLogFilename_();
125 void maybeRedirectReservoirCouplingSlaveOutput_();
136 int exitCode = EXIT_SUCCESS;
139 if (isSimulationRank_) {
140 return this->dispatchDynamic_();
154 template <
class TypeTag>
157 int exitCode = EXIT_SUCCESS;
159 if (isSimulationRank_) {
160 return this->dispatchStatic_<TypeTag>();
170 int exitCode = EXIT_SUCCESS;
183 template <
class TypeTagEarlyBird>
186 Dune::Timer externalSetupTimer;
187 externalSetupTimer.start();
201 typedef TypeTagEarlyBird PreTypeTag;
204 PreProblem::setBriefDescription(
"Flow, an advanced reservoir simulator for ECL-decks provided by the Open Porous Media project.");
212 MPI_Abort(MPI_COMM_WORLD, status);
214 exitCode = (status > 0) ? status : EXIT_SUCCESS;
220 std::string deckFilename;
221 std::string outputDir;
222 if ( eclipseState_ ) {
223 deckFilename = eclipseState_->getIOConfig().fullBasePath();
224 outputDir = eclipseState_->getIOConfig().getOutputDir();
237 msg =
"\nUse of Damaris (command line argument --enable-damaris-output=true) has been disabled for run with only one rank.\n" ;
238 OpmLog::warning(msg);
239 enableDamarisOutput_ = false ;
242 if (enableDamarisOutput_) {
244 auto damarisOutputDir = outputDir;
245 if (outputDir.empty()) {
246 auto odir = std::filesystem::path{deckFilename}.parent_path();
248 damarisOutputDir =
".";
250 damarisOutputDir = odir.generic_string();
254 this->setupDamaris(damarisOutputDir);
260 if (!isSimulationRank_) {
261 exitCode = EXIT_SUCCESS;
270 if (deckFilename.empty()) {
272 std::cerr <<
"No input case given. Try '--help' for a usage description.\n";
274 exitCode = EXIT_FAILURE;
280 deckFilename = PreVanguard::canonicalDeckPath(deckFilename);
282 catch (
const std::exception& e) {
283 if ( mpiRank == 0 ) {
284 std::cerr <<
"Exception received: " << e.what() <<
". Try '--help' for a usage description.\n";
287 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
289 exitCode = EXIT_FAILURE;
293 std::string cmdline_params;
298 std::ostringstream str;
300 cmdline_params = str.str();
305 this->readDeck(deckFilename,
320 setupTime_ = externalSetupTimer.elapsed();
326 catch (
const std::runtime_error& e)
329 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
330 std::cerr << e.what() << std::endl;
332 exitCode = EXIT_FAILURE;
338 catch (
const std::exception& e)
341 std::cerr <<
"Unexpected error during initialization." << std::endl;
342 std::cerr <<
"Exception caught: " << e.what() << std::endl;
345 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
347 exitCode = EXIT_FAILURE;
352 Opm::gpuistl::printDevice();
355 exitCode = EXIT_SUCCESS;
359 void setupVanguard();
369 void handleVersionCmdLine_(
int argc,
char** argv,
378 void handleTestSplitCommunicatorCmdLine_();
385 int dispatchDynamic_();
395 template <
class TypeTag>
396 int dispatchStatic_()
398 this->setupVanguard();
399 return flowMain<TypeTag>(argc_, argv_, outputCout_, outputFiles_);
410 int runMICP(
const Phases& phases);
420 int runTwoPhase(
const Phases& phases);
430 int runBiofilm(
const Phases& phases);
440 int runPolymer(
const Phases& phases);
457 int runWaterOnly(
const Phases& phases);
467 int runWaterOnlyEnergy(
const Phases& phases);
477 int runBrine(
const Phases& phases);
487 int runSolvent(
const Phases& phases);
494 int runExtendedBlackOil();
504 int runThermal(
const Phases& phases);
512 int runBlackOilTemp();
523 void readDeck(
const std::string& deckFilename,
524 const std::string& outputDir,
525 const std::string& outputMode,
526 const bool init_from_restart_file,
527 const bool allRanksDbgPrtLog,
528 const std::string& parsingStrictness,
529 const std::string& actionParsingStrictness,
530 const std::string& inputSkipMode,
531 const bool keepKeywords,
532 const std::size_t numThreads,
533 const int output_param,
534 const bool slaveMode,
535 const std::string& parameters,
539 static int getNumThreads();
542 void setupDamaris(
const std::string& outputDir);
547 char** argv_{
nullptr};
548 bool outputCout_{
false};
549 bool outputFiles_{
false};
553 double setupTime_{0.0};
554 std::string deckFilename_{};
555 std::string flowProgName_{};
556 char *saveArgs_[3]{
nullptr};
557 std::unique_ptr<UDQState> udqState_{};
558 std::unique_ptr<Action::State> actionState_{};
559 std::unique_ptr<WellTestState> wtestState_{};
562 std::shared_ptr<EclipseState> eclipseState_{};
563 std::shared_ptr<Schedule> schedule_{};
564 std::shared_ptr<SummaryConfig> summaryConfig_{};
565 bool mpi_init_{
true};
566 bool mpi_finalize_{
true};
569 bool test_split_comm_ =
false;
570 bool isSimulationRank_ =
true;
572 std::string reservoirCouplingSlaveOutputFilename_{};
575 bool enableDamarisOutput_ =
false;
This problem simulates an input file given in the data format used by the commercial ECLiPSE simulato...
static Parallel::Communication & comm()
Obtain global communicator.
Definition FlowGenericVanguard.hpp:336
int justInitialize()
Used for test_outputdir.
Definition Main.hpp:168
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition Main.hpp:184
int runDynamic()
Run simulation.
Definition Main.hpp:134
int runStatic()
Run simulation.
Definition Main.hpp:155
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:82
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
std::string moduleVersionName()
Return the version name of the module, for example "2015.10" (for a release branch) or "2016....
Definition moduleVersion.cpp:34
std::string compileTimestamp()
Return a string "dd-mm-yyyy at HH::MM::SS hrs" which is the time the binary was compiled.
Definition moduleVersion.cpp:57
std::string moduleVersion()
Return a string containing both the name and hash, if N is the name and H is the hash it will be "N (...
Definition moduleVersion.cpp:50
void printValues(std::ostream &os)
Print values of the run-time parameters.
Definition parametersystem.cpp:742
void reset()
Reset parameter system.
Definition parametersystem.cpp:486
This file provides the infrastructure to retrieve run-time parameters.
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition parametersystem.hpp:187
The Opm property system, traits with inheritance.