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>
80template<
class TypeTag>
82{
static constexpr bool value =
false; };
85template<
class TypeTag>
87{
static constexpr bool value =
false; };
93namespace Action {
class State; }
98template <
class TypeTag>
99int flowMain(
int argc,
char** argv,
bool outputCout,
bool outputFiles)
105 FlowMain<TypeTag> mainfunc(argc, argv, outputCout, outputFiles);
106 return mainfunc.execute();
119 Main(
int argc,
char** argv,
bool ownMPI =
true);
122 explicit Main(
const std::string& filename,
bool mpi_init =
true,
bool mpi_finalize =
true);
126 Main(
const std::string& filename,
127 std::shared_ptr<EclipseState> eclipseState,
128 std::shared_ptr<Schedule> schedule,
129 std::shared_ptr<SummaryConfig> summaryConfig,
130 bool mpi_init =
true,
131 bool mpi_finalize =
true);
148 int exitCode = EXIT_SUCCESS;
149 if (initialize_<Properties::TTag::FlowEarlyBird>(exitCode)) {
151 if (isSimulationRank_) {
152 return this->dispatchDynamic_();
166 template <
class TypeTag>
169 int exitCode = EXIT_SUCCESS;
170 if (initialize_<TypeTag>(exitCode)) {
171 if (isSimulationRank_) {
172 return this->dispatchStatic_<TypeTag>();
182 int exitCode = EXIT_SUCCESS;
183 initialize_<Properties::TTag::FlowEarlyBird>(exitCode);
195 template <
class TypeTagEarlyBird>
198 Dune::Timer externalSetupTimer;
199 externalSetupTimer.start();
213 typedef TypeTagEarlyBird PreTypeTag;
216 PreProblem::setBriefDescription(
"Flow, an advanced reservoir simulator for ECL-decks provided by the Open Porous Media project.");
224 MPI_Abort(MPI_COMM_WORLD, status);
226 exitCode = (status > 0) ? status : EXIT_SUCCESS;
230 OpmLog::setDebugVerbosityLevel(Parameters::Get<Parameters::DebugVerbosityLevel>());
232 std::string deckFilename;
233 std::string outputDir;
234 if ( eclipseState_ ) {
235 deckFilename = eclipseState_->getIOConfig().fullBasePath();
236 outputDir = eclipseState_->getIOConfig().getOutputDir();
239 deckFilename = Parameters::Get<Parameters::EclDeckFileName>();
240 outputDir = Parameters::Get<Parameters::OutputDir>();
244 enableDamarisOutput_ = Parameters::Get<Parameters::EnableDamarisOutput>();
249 msg =
"\nUse of Damaris (command line argument --enable-damaris-output=true) has been disabled for run with only one rank.\n" ;
250 OpmLog::warning(msg);
251 enableDamarisOutput_ = false ;
254 if (enableDamarisOutput_) {
256 auto damarisOutputDir = outputDir;
257 if (outputDir.empty()) {
258 auto odir = std::filesystem::path{deckFilename}.parent_path();
260 damarisOutputDir =
".";
262 damarisOutputDir = odir.generic_string();
266 this->setupDamaris(damarisOutputDir);
272 if (!isSimulationRank_) {
273 exitCode = EXIT_SUCCESS;
280 outputCout_ = Parameters::Get<Parameters::EnableTerminalOutput>();
282 if (deckFilename.empty()) {
284 std::cerr <<
"No input case given. Try '--help' for a usage description.\n";
286 exitCode = EXIT_FAILURE;
292 deckFilename = PreVanguard::canonicalDeckPath(deckFilename);
294 catch (
const std::exception& e) {
295 if ( mpiRank == 0 ) {
296 std::cerr <<
"Exception received: " << e.what() <<
". Try '--help' for a usage description.\n";
299 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
301 exitCode = EXIT_FAILURE;
305 std::string cmdline_params;
310 std::ostringstream str;
312 cmdline_params = str.str();
317 this->readDeck(deckFilename,
319 Parameters::Get<Parameters::OutputMode>(),
320 !Parameters::Get<Parameters::SchedRestart>(),
321 Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
322 Parameters::Get<Parameters::ParsingStrictness>(),
323 Parameters::Get<Parameters::ActionParsingStrictness>(),
324 Parameters::Get<Parameters::InputSkipMode>(),
327 Parameters::Get<Parameters::EclOutputInterval>(),
328 Parameters::Get<Parameters::Slave>(),
332 setupTime_ = externalSetupTimer.elapsed();
338 catch (
const std::runtime_error& e)
341 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
342 std::cerr << e.what() << std::endl;
344 exitCode = EXIT_FAILURE;
350 catch (
const std::exception& e)
353 std::cerr <<
"Unexpected error during initialization." << std::endl;
354 std::cerr <<
"Exception caught: " << e.what() << std::endl;
357 MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
359 exitCode = EXIT_FAILURE;
367 exitCode = EXIT_SUCCESS;
381 void handleVersionCmdLine_(
int argc,
char** argv,
390 void handleTestSplitCommunicatorCmdLine_();
397 int dispatchDynamic_();
407 template <
class TypeTag>
408 int dispatchStatic_()
422 int runMICP(
const Phases& phases);
432 int runTwoPhase(
const Phases& phases);
442 int runBiofilm(
const Phases& phases);
452 int runPolymer(
const Phases& phases);
469 int runWaterOnly(
const Phases& phases);
479 int runWaterOnlyEnergy(
const Phases& phases);
489 int runBrine(
const Phases& phases);
499 int runSolvent(
const Phases& phases);
506 int runExtendedBlackOil();
516 int runThermal(
const Phases& phases);
524 int runBlackOilTemp();
535 void readDeck(
const std::string& deckFilename,
536 const std::string& outputDir,
537 const std::string& outputMode,
538 const bool init_from_restart_file,
539 const bool allRanksDbgPrtLog,
540 const std::string& parsingStrictness,
541 const std::string& actionParsingStrictness,
542 const std::string& inputSkipMode,
543 const bool keepKeywords,
544 const std::size_t numThreads,
545 const int output_param,
546 const bool slaveMode,
547 const std::string& parameters,
551 static int getNumThreads();
554 void setupDamaris(
const std::string& outputDir);
565 double setupTime_{0.0};
566 std::string deckFilename_{};
567 std::string flowProgName_{};
568 char *saveArgs_[3]{
nullptr};
569 std::unique_ptr<UDQState> udqState_{};
570 std::unique_ptr<Action::State> actionState_{};
571 std::unique_ptr<WellTestState> wtestState_{};
574 std::shared_ptr<EclipseState> eclipseState_{};
575 std::shared_ptr<Schedule> schedule_{};
576 std::shared_ptr<SummaryConfig> summaryConfig_{};
577 bool mpi_init_{
true};
578 bool mpi_finalize_{
true};
581 bool test_split_comm_ =
false;
582 bool isSimulationRank_ =
true;
584 std::string reservoirCouplingSlaveOutputFilename_{};
587 bool enableDamarisOutput_ =
false;
static Parallel::Communication & comm()
Obtain global communicator.
Definition: FlowGenericVanguard.hpp:336
int argc_
Definition: Main.hpp:558
int justInitialize()
Used for test_outputdir.
Definition: Main.hpp:180
void maybeSaveReservoirCouplingSlaveLogFilename_()
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition: Main.hpp:196
bool outputFiles_
Definition: Main.hpp:561
void maybeRedirectReservoirCouplingSlaveOutput_()
int runDynamic()
Definition: Main.hpp:146
Main(int argc, char **argv, bool ownMPI=true)
char ** argv_
Definition: Main.hpp:559
Main(const std::string &filename, bool mpi_init=true, bool mpi_finalize=true)
int runStatic()
Definition: Main.hpp:167
void setArgvArgc_(const std::string &filename)
bool outputCout_
Definition: Main.hpp:560
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:99
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:74