23#ifndef OPM_MAIN_HEADER_INCLUDED
24#define OPM_MAIN_HEADER_INCLUDED
26#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
31#include <opm/simulators/flow/Banners.hpp>
32#include <opm/simulators/flow/FlowMain.hpp>
36#include <dune/fem/misc/mpimanager.hh>
38#include <dune/common/parallel/mpihelper.hh>
42#include <opm/simulators/utils/ParallelEclipseState.hpp>
46#include <opm/simulators/linalg/gpuistl/device_management.hpp>
50#include <opm/simulators/utils/DamarisKeywords.hpp>
65namespace Opm::Properties {
71 using InheritsFrom = std::tuple<FlowProblem>;
79namespace Action {
class State; }
84template <
class TypeTag>
85int flowMain(
int argc,
char** argv,
bool outputCout,
bool outputFiles)
91 FlowMain<TypeTag> mainfunc(argc, argv, outputCout, outputFiles);
92 return mainfunc.execute();
105 Main(
int argc,
char** argv,
bool ownMPI =
true);
108 explicit Main(
const std::string& filename,
bool mpi_init =
true,
bool mpi_finalize =
true);
112 Main(
const std::string& filename,
113 std::shared_ptr<EclipseState> eclipseState,
114 std::shared_ptr<Schedule> schedule,
115 std::shared_ptr<SummaryConfig> summaryConfig,
116 bool mpi_init =
true,
117 bool mpi_finalize =
true);
121 void setArgvArgc_(
const std::string& filename);
122 void maybeSaveReservoirCouplingSlaveLogFilename_();
123 void maybeRedirectReservoirCouplingSlaveOutput_();
134 int exitCode = EXIT_SUCCESS;
137 if (isSimulationRank_) {
138 return this->dispatchDynamic_();
152 template <
class TypeTag>
155 int exitCode = EXIT_SUCCESS;
157 if (isSimulationRank_) {
158 return this->dispatchStatic_<TypeTag>();
168 int exitCode = EXIT_SUCCESS;
181 template <
class TypeTagEarlyBird>
184 Dune::Timer externalSetupTimer;
185 externalSetupTimer.start();
199 typedef TypeTagEarlyBird PreTypeTag;
202 PreProblem::setBriefDescription(
"Flow, an advanced reservoir simulator for ECL-decks provided by the Open Porous Media project.");
210 MPI_Abort(MPI_COMM_WORLD, status);
212 exitCode = (status > 0) ? status : EXIT_SUCCESS;
218 std::string deckFilename;
219 std::string outputDir;
220 if ( eclipseState_ ) {
221 deckFilename = eclipseState_->getIOConfig().fullBasePath();
222 outputDir = eclipseState_->getIOConfig().getOutputDir();
235 msg =
"\nUse of Damaris (command line argument --enable-damaris-output=true) has been disabled for run with only one rank.\n" ;
236 OpmLog::warning(msg);
237 enableDamarisOutput_ = false ;
240 if (enableDamarisOutput_) {
242 auto damarisOutputDir = outputDir;
243 if (outputDir.empty()) {
244 auto odir = std::filesystem::path{deckFilename}.parent_path();
246 damarisOutputDir =
".";
248 damarisOutputDir = odir.generic_string();
252 this->setupDamaris(damarisOutputDir);
258 if (!isSimulationRank_) {
259 exitCode = EXIT_SUCCESS;
268 if (deckFilename.empty()) {
270 std::cerr <<
"No input case given. Try '--help' for a usage description.\n";
272 exitCode = EXIT_FAILURE;
278 deckFilename = PreVanguard::canonicalDeckPath(deckFilename);
280 catch (
const std::exception& e) {
281 if ( mpiRank == 0 ) {
282 std::cerr <<
"Exception received: " << e.what() <<
". Try '--help' for a usage description.\n";
285 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
287 exitCode = EXIT_FAILURE;
291 std::string cmdline_params;
296 std::ostringstream str;
298 cmdline_params = str.str();
303 this->readDeck(deckFilename,
318 setupTime_ = externalSetupTimer.elapsed();
320 catch (
const std::invalid_argument& e)
323 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
324 std::cerr <<
"Exception caught: " << e.what() << std::endl;
327 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
329 exitCode = EXIT_FAILURE;
334 Opm::gpuistl::printDevice();
337 exitCode = EXIT_SUCCESS;
341 void setupVanguard();
351 void handleVersionCmdLine_(
int argc,
char** argv,
360 void handleTestSplitCommunicatorCmdLine_();
367 int dispatchDynamic_();
377 template <
class TypeTag>
378 int dispatchStatic_()
380 this->setupVanguard();
381 return flowMain<TypeTag>(argc_, argv_, outputCout_, outputFiles_);
392 int runMICP(
const Phases& phases);
402 int runTwoPhase(
const Phases& phases);
412 int runBiofilm(
const Phases& phases);
422 int runPolymer(
const Phases& phases);
439 int runWaterOnly(
const Phases& phases);
449 int runWaterOnlyEnergy(
const Phases& phases);
459 int runBrine(
const Phases& phases);
469 int runSolvent(
const Phases& phases);
476 int runExtendedBlackOil();
486 int runThermal(
const Phases& phases);
495 void readDeck(
const std::string& deckFilename,
496 const std::string& outputDir,
497 const std::string& outputMode,
498 const bool init_from_restart_file,
499 const bool allRanksDbgPrtLog,
500 const std::string& parsingStrictness,
501 const std::string& actionParsingStrictness,
502 const std::string& inputSkipMode,
503 const bool keepKeywords,
504 const std::size_t numThreads,
505 const int output_param,
506 const bool slaveMode,
507 const std::string& parameters,
511 static int getNumThreads()
514 return omp_get_max_threads();
521 void setupDamaris(
const std::string& outputDir);
526 char** argv_{
nullptr};
527 bool outputCout_{
false};
528 bool outputFiles_{
false};
532 double setupTime_{0.0};
533 std::string deckFilename_{};
534 std::string flowProgName_{};
535 char *saveArgs_[3]{
nullptr};
536 std::unique_ptr<UDQState> udqState_{};
537 std::unique_ptr<Action::State> actionState_{};
538 std::unique_ptr<WellTestState> wtestState_{};
541 std::shared_ptr<EclipseState> eclipseState_{};
542 std::shared_ptr<Schedule> schedule_{};
543 std::shared_ptr<SummaryConfig> summaryConfig_{};
544 bool mpi_init_{
true};
545 bool mpi_finalize_{
true};
548 bool test_split_comm_ =
false;
549 bool isSimulationRank_ =
true;
551 std::string reservoirCouplingSlaveOutputFilename_{};
554 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:166
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition Main.hpp:182
int runDynamic()
Run simulation.
Definition Main.hpp:132
int runStatic()
Run simulation.
Definition Main.hpp:153
The generic type tag for problems using the immiscible multi-phase model.
Definition blackoilmodel.hh:81
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
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:741
void reset()
Reset parameter system.
Definition parametersystem.cpp:485
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.