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>
81template<
class TypeTag>
83{
static constexpr bool value =
false; };
86template<
class TypeTag>
88{
static constexpr bool value =
false; };
94namespace Action {
class State; }
99template <
class TypeTag>
100int flowMain(
int argc,
char** argv,
bool outputCout,
bool outputFiles)
106 FlowMain<TypeTag> mainfunc(argc, argv, outputCout, outputFiles);
107 return mainfunc.execute();
120 Main(
int argc,
char** argv,
bool ownMPI =
true);
123 explicit Main(
const std::string& filename,
bool mpi_init =
true,
bool mpi_finalize =
true);
127 Main(
const std::string& filename,
128 std::shared_ptr<EclipseState> eclipseState,
129 std::shared_ptr<Schedule> schedule,
130 std::shared_ptr<SummaryConfig> summaryConfig,
131 bool mpi_init =
true,
132 bool mpi_finalize =
true);
149 int exitCode = EXIT_SUCCESS;
150 if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) {
152 if (isSimulationRank_) {
153 return this->dispatchDynamic_();
167 template <
class TypeTag>
170 int exitCode = EXIT_SUCCESS;
171 if (initialize_<TypeTag>(exitCode)) {
172 if (isSimulationRank_) {
173 return this->dispatchStatic_<TypeTag>();
183 int exitCode = EXIT_SUCCESS;
184 initialize_<Properties::TTag::FlowEarlyBird>(exitCode);
196 template <
class TypeTagEarlyBird>
199 Dune::Timer externalSetupTimer;
200 externalSetupTimer.start();
214 typedef TypeTagEarlyBird PreTypeTag;
217 PreProblem::setBriefDescription(
"Flow, an advanced reservoir simulator for ECL-decks provided by the Open Porous Media project.");
225 MPI_Abort(MPI_COMM_WORLD, status);
227 exitCode = (status > 0) ? status : EXIT_SUCCESS;
231 OpmLog::setDebugVerbosityLevel(Parameters::Get<Parameters::DebugVerbosityLevel>());
233 std::string deckFilename;
234 std::string outputDir;
235 if ( eclipseState_ ) {
236 deckFilename = eclipseState_->getIOConfig().fullBasePath();
237 outputDir = eclipseState_->getIOConfig().getOutputDir();
240 deckFilename = Parameters::Get<Parameters::EclDeckFileName>();
241 outputDir = Parameters::Get<Parameters::OutputDir>();
245 enableDamarisOutput_ = Parameters::Get<Parameters::EnableDamarisOutput>();
250 msg =
"\nUse of Damaris (command line argument --enable-damaris-output=true) has been disabled for run with only one rank.\n" ;
251 OpmLog::warning(msg);
252 enableDamarisOutput_ = false ;
255 if (enableDamarisOutput_) {
257 auto damarisOutputDir = outputDir;
258 if (outputDir.empty()) {
259 auto odir = std::filesystem::path{deckFilename}.parent_path();
261 damarisOutputDir =
".";
263 damarisOutputDir = odir.generic_string();
267 this->setupDamaris(damarisOutputDir);
273 if (!isSimulationRank_) {
274 exitCode = EXIT_SUCCESS;
281 outputCout_ = Parameters::Get<Parameters::EnableTerminalOutput>();
283 if (deckFilename.empty()) {
285 std::cerr <<
"No input case given. Try '--help' for a usage description.\n";
287 exitCode = EXIT_FAILURE;
293 deckFilename = PreVanguard::canonicalDeckPath(deckFilename);
295 catch (
const std::exception& e) {
296 if ( mpiRank == 0 ) {
297 std::cerr <<
"Exception received: " << e.what() <<
". Try '--help' for a usage description.\n";
300 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
302 exitCode = EXIT_FAILURE;
306 std::string cmdline_params;
311 std::ostringstream str;
313 cmdline_params = str.str();
318 this->readDeck(deckFilename,
320 Parameters::Get<Parameters::OutputMode>(),
321 !Parameters::Get<Parameters::SchedRestart>(),
322 Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
323 Parameters::Get<Parameters::ParsingStrictness>(),
324 Parameters::Get<Parameters::ActionParsingStrictness>(),
325 Parameters::Get<Parameters::InputSkipMode>(),
328 Parameters::Get<Parameters::EclOutputInterval>(),
329 Parameters::Get<Parameters::Slave>(),
333 setupTime_ = externalSetupTimer.elapsed();
339 catch (
const std::runtime_error& e)
342 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
343 std::cerr << e.what() << std::endl;
349 notifyMasterSlaveInitFailed_();
351 exitCode = EXIT_FAILURE;
357 catch (
const std::exception& e)
360 std::cerr <<
"Unexpected error during initialization." << std::endl;
361 std::cerr <<
"Exception caught: " << e.what() << std::endl;
364 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
366 exitCode = EXIT_FAILURE;
374 exitCode = EXIT_SUCCESS;
388 void handleVersionCmdLine_(
int argc,
char** argv,
397 void handleTestSplitCommunicatorCmdLine_();
401 void notifyMasterSlaveInitFailed_();
408 int dispatchDynamic_();
418 template <
class TypeTag>
419 int dispatchStatic_()
433 int runMICP(
const Phases& phases);
443 int runTwoPhase(
const Phases& phases);
453 int runBiofilm(
const Phases& phases);
463 int runPolymer(
const Phases& phases);
480 int runWaterOnly(
const Phases& phases);
490 int runWaterOnlyEnergy(
const Phases& phases);
500 int runBrine(
const Phases& phases);
510 int runSolvent(
const Phases& phases);
517 int runExtendedBlackOil();
527 int runThermal(
const Phases& phases);
535 int runBlackOilTemp();
546 void readDeck(
const std::string& deckFilename,
547 const std::string& outputDir,
548 const std::string& outputMode,
549 const bool init_from_restart_file,
550 const bool allRanksDbgPrtLog,
551 const std::string& parsingStrictness,
552 const std::string& actionParsingStrictness,
553 const std::string& inputSkipMode,
554 const bool keepKeywords,
555 const std::size_t numThreads,
556 const int output_param,
557 const bool slaveMode,
558 const std::string& parameters,
562 static int getNumThreads();
565 void setupDamaris(
const std::string& outputDir);
576 double setupTime_{0.0};
577 std::string deckFilename_{};
578 std::string flowProgName_{};
579 char *saveArgs_[3]{
nullptr};
580 std::unique_ptr<UDQState> udqState_{};
581 std::unique_ptr<Action::State> actionState_{};
582 std::unique_ptr<WellTestState> wtestState_{};
585 std::shared_ptr<EclipseState> eclipseState_{};
586 std::shared_ptr<Schedule> schedule_{};
587 std::shared_ptr<SummaryConfig> summaryConfig_{};
588 bool mpi_init_{
true};
589 bool mpi_finalize_{
true};
592 bool test_split_comm_ =
false;
593 bool isSimulationRank_ =
true;
595 std::string reservoirCouplingSlaveOutputFilename_{};
598 bool enableDamarisOutput_ =
false;
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:336
int argc_
Definition: Main.hpp:569
int justInitialize()
Used for test_outputdir.
Definition: Main.hpp:181
void maybeSaveReservoirCouplingSlaveLogFilename_()
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition: Main.hpp:197
bool outputFiles_
Definition: Main.hpp:572
void maybeRedirectReservoirCouplingSlaveOutput_()
int runDynamic()
Definition: Main.hpp:147
Main(int argc, char **argv, bool ownMPI=true)
char ** argv_
Definition: Main.hpp:570
Main(const std::string &filename, bool mpi_init=true, bool mpi_finalize=true)
int runStatic()
Definition: Main.hpp:168
void setArgvArgc_(const std::string &filename)
bool outputCout_
Definition: Main.hpp:571
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:75
Definition: blackoilbioeffectsmodules.hh:45
std::string moduleVersionName()
int flowMain(int argc, char **argv, bool outputCout, bool outputFiles)
Definition: Main.hpp:100
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.
Enable convective mixing?
Definition: multiphasebaseproperties.hh:99
Enable diffusive fluxes?
Definition: multiphasebaseproperties.hh:91
std::tuple< FlowProblem > InheritsFrom
Definition: Main.hpp:75