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>
38#include <dune/fem/misc/mpimanager.hh>
40#include <dune/common/parallel/mpihelper.hh>
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);
136 int exitCode = EXIT_SUCCESS;
137 if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) {
139 if (isSimulationRank_) {
140 return this->dispatchDynamic_();
154 template <
class TypeTag>
157 int exitCode = EXIT_SUCCESS;
158 if (initialize_<TypeTag>(exitCode)) {
159 if (isSimulationRank_) {
160 return this->dispatchStatic_<TypeTag>();
170 int exitCode = EXIT_SUCCESS;
171 initialize_<Properties::TTag::FlowEarlyBird>(exitCode);
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;
218 OpmLog::setDebugVerbosityLevel(Parameters::Get<Parameters::DebugVerbosityLevel>());
220 std::string deckFilename;
221 std::string outputDir;
222 if ( eclipseState_ ) {
223 deckFilename = eclipseState_->getIOConfig().fullBasePath();
224 outputDir = eclipseState_->getIOConfig().getOutputDir();
227 deckFilename = Parameters::Get<Parameters::EclDeckFileName>();
228 outputDir = Parameters::Get<Parameters::OutputDir>();
232 enableDamarisOutput_ = Parameters::Get<Parameters::EnableDamarisOutput>();
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;
268 outputCout_ = Parameters::Get<Parameters::EnableTerminalOutput>();
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,
307 Parameters::Get<Parameters::OutputMode>(),
308 !Parameters::Get<Parameters::SchedRestart>(),
309 Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
310 Parameters::Get<Parameters::ParsingStrictness>(),
311 Parameters::Get<Parameters::ActionParsingStrictness>(),
312 Parameters::Get<Parameters::InputSkipMode>(),
315 Parameters::Get<Parameters::EclOutputInterval>(),
316 Parameters::Get<Parameters::Slave>(),
320 setupTime_ = externalSetupTimer.elapsed();
322 catch (
const std::invalid_argument& e)
325 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
326 std::cerr <<
"Exception caught: " << e.what() << std::endl;
329 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
331 exitCode = EXIT_FAILURE;
339 exitCode = EXIT_SUCCESS;
353 void handleVersionCmdLine_(
int argc,
char** argv,
362 void handleTestSplitCommunicatorCmdLine_();
369 int dispatchDynamic_();
379 template <
class TypeTag>
380 int dispatchStatic_()
394 int runMICP(
const Phases& phases);
404 int runTwoPhase(
const Phases& phases);
414 int runBiofilm(
const Phases& phases);
424 int runPolymer(
const Phases& phases);
441 int runWaterOnly(
const Phases& phases);
451 int runWaterOnlyEnergy(
const Phases& phases);
461 int runBrine(
const Phases& phases);
471 int runSolvent(
const Phases& phases);
478 int runExtendedBlackOil();
488 int runThermal(
const Phases& phases);
496 int runBlackOilTemp();
507 void readDeck(
const std::string& deckFilename,
508 const std::string& outputDir,
509 const std::string& outputMode,
510 const bool init_from_restart_file,
511 const bool allRanksDbgPrtLog,
512 const std::string& parsingStrictness,
513 const std::string& actionParsingStrictness,
514 const std::string& inputSkipMode,
515 const bool keepKeywords,
516 const std::size_t numThreads,
517 const int output_param,
518 const bool slaveMode,
519 const std::string& parameters,
523 static int getNumThreads()
526 return omp_get_max_threads();
533 void setupDamaris(
const std::string& outputDir);
544 double setupTime_{0.0};
545 std::string deckFilename_{};
546 std::string flowProgName_{};
547 char *saveArgs_[3]{
nullptr};
548 std::unique_ptr<UDQState> udqState_{};
549 std::unique_ptr<Action::State> actionState_{};
550 std::unique_ptr<WellTestState> wtestState_{};
553 std::shared_ptr<EclipseState> eclipseState_{};
554 std::shared_ptr<Schedule> schedule_{};
555 std::shared_ptr<SummaryConfig> summaryConfig_{};
556 bool mpi_init_{
true};
557 bool mpi_finalize_{
true};
560 bool test_split_comm_ =
false;
561 bool isSimulationRank_ =
true;
563 std::string reservoirCouplingSlaveOutputFilename_{};
566 bool enableDamarisOutput_ =
false;
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:336
int argc_
Definition: Main.hpp:537
int justInitialize()
Used for test_outputdir.
Definition: Main.hpp:168
void maybeSaveReservoirCouplingSlaveLogFilename_()
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition: Main.hpp:184
bool outputFiles_
Definition: Main.hpp:540
void maybeRedirectReservoirCouplingSlaveOutput_()
int runDynamic()
Definition: Main.hpp:134
Main(int argc, char **argv, bool ownMPI=true)
char ** argv_
Definition: Main.hpp:538
Main(const std::string &filename, bool mpi_init=true, bool mpi_finalize=true)
int runStatic()
Definition: Main.hpp:155
void setArgvArgc_(const std::string &filename)
bool outputCout_
Definition: Main.hpp:539
Main(const std::string &filename, std::shared_ptr< EclipseState > eclipseState, std::shared_ptr< Schedule > schedule, std::shared_ptr< SummaryConfig > summaryConfig, bool mpi_init=true, bool mpi_finalize=true)
void printValues(std::ostream &os)
Print values of the run-time parameters.
void reset()
Reset parameter system.
Definition: blackoilmodel.hh:80
Definition: blackoilbioeffectsmodules.hh:43
std::string moduleVersionName()
int flowMain(int argc, char **argv, bool outputCout, bool outputFiles)
Definition: Main.hpp:87
std::string compileTimestamp()
void printFlowBanner(int nprocs, int threads, std::string_view moduleVersionName)
std::string moduleVersion()
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
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
std::tuple< FlowProblem > InheritsFrom
Definition: Main.hpp:73