23#ifndef OPM_MAIN_HEADER_INCLUDED
24#define OPM_MAIN_HEADER_INCLUDED
26#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
36#include <dune/fem/misc/mpimanager.hh>
38#include <dune/common/parallel/mpihelper.hh>
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);
134 int exitCode = EXIT_SUCCESS;
135 if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) {
137 if (isSimulationRank_) {
138 return this->dispatchDynamic_();
152 template <
class TypeTag>
155 int exitCode = EXIT_SUCCESS;
156 if (initialize_<TypeTag>(exitCode)) {
157 if (isSimulationRank_) {
158 return this->dispatchStatic_<TypeTag>();
168 int exitCode = EXIT_SUCCESS;
169 initialize_<Properties::TTag::FlowEarlyBird>(exitCode);
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;
216 OpmLog::setDebugVerbosityLevel(Parameters::Get<Parameters::DebugVerbosityLevel>());
218 std::string deckFilename;
219 std::string outputDir;
220 if ( eclipseState_ ) {
221 deckFilename = eclipseState_->getIOConfig().fullBasePath();
222 outputDir = eclipseState_->getIOConfig().getOutputDir();
225 deckFilename = Parameters::Get<Parameters::EclDeckFileName>();
226 outputDir = Parameters::Get<Parameters::OutputDir>();
230 enableDamarisOutput_ = Parameters::Get<Parameters::EnableDamarisOutput>();
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;
266 outputCout_ = Parameters::Get<Parameters::EnableTerminalOutput>();
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,
305 Parameters::Get<Parameters::OutputMode>(),
306 !Parameters::Get<Parameters::SchedRestart>(),
307 Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
308 Parameters::Get<Parameters::ParsingStrictness>(),
309 Parameters::Get<Parameters::ActionParsingStrictness>(),
310 Parameters::Get<Parameters::InputSkipMode>(),
313 Parameters::Get<Parameters::EclOutputInterval>(),
314 Parameters::Get<Parameters::Slave>(),
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;
337 exitCode = EXIT_SUCCESS;
351 void handleVersionCmdLine_(
int argc,
char** argv,
360 void handleTestSplitCommunicatorCmdLine_();
367 int dispatchDynamic_();
377 template <
class TypeTag>
378 int dispatchStatic_()
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);
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;
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:336
int argc_
Definition: Main.hpp:525
int justInitialize()
Used for test_outputdir.
Definition: Main.hpp:166
void maybeSaveReservoirCouplingSlaveLogFilename_()
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition: Main.hpp:182
bool outputFiles_
Definition: Main.hpp:528
void maybeRedirectReservoirCouplingSlaveOutput_()
int runDynamic()
Definition: Main.hpp:132
Main(int argc, char **argv, bool ownMPI=true)
char ** argv_
Definition: Main.hpp:526
Main(const std::string &filename, bool mpi_init=true, bool mpi_finalize=true)
int runStatic()
Definition: Main.hpp:153
void setArgvArgc_(const std::string &filename)
bool outputCout_
Definition: Main.hpp:527
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:79
Definition: blackoilbioeffectsmodules.hh:43
std::string moduleVersionName()
int flowMain(int argc, char **argv, bool outputCout, bool outputFiles)
Definition: Main.hpp:85
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:71