139 std::shared_ptr<EclipseState> eclipseState,
140 std::shared_ptr<Schedule> schedule,
141 std::shared_ptr<SummaryConfig> summaryConfig,
147 void setArgvArgc_(
const std::string&
filename);
156 if (isSimulationRank_) {
157 return this->dispatchDynamic_();
164 template <
class TypeTag>
169 if (isSimulationRank_) {
186 int dispatchDynamic_()
188 const auto&
rspec = this->eclipseState_->runspec();
191 this->setupVanguard();
197 const bool thermal = eclipseState_->getSimulationConfig().isThermal();
201 return this->runMICP(
phases);
206 return this->runWaterOnly(
phases);
211 return this->runWaterOnlyEnergy(
phases);
216 return this->runTwoPhase(
phases);
220 else if (
phases.active(Phase::POLYMER)) {
221 return this->runPolymer(
phases);
225 else if (
phases.active(Phase::FOAM) && !
phases.active(Phase::SOLVENT)) {
226 return this->runFoam();
230 else if (
phases.active(Phase::SOLVENT)) {
231 return this->runSolvent(
phases);
236 return this->runBrine(
phases);
240 else if (
phases.active(Phase::ZFRACTION)) {
241 return this->runExtendedBlackOil();
246 return this->runThermal(
phases);
250 else if (
phases.size() == 3) {
251 return this->runBlackOil();
256 std::cerr <<
"No suitable configuration found, valid are "
257 <<
"Twophase, polymer, foam, brine, solvent, "
258 <<
"energy, and blackoil.\n";
265 template <
class TypeTag>
266 int dispatchStatic_()
268 this->setupVanguard();
280 template <
class TypeTagEarlyBird>
301 PreProblem::setBriefDescription(
"Flow, an advanced reservoir simulator for ECL-decks provided by the Open Porous Media project.");
316 std::string outputDir;
317 if ( eclipseState_ ) {
318 deckFilename = eclipseState_->getIOConfig().fullBasePath();
319 outputDir = eclipseState_->getIOConfig().getOutputDir();
322 deckFilename = Parameters::Get<Parameters::EclDeckFileName>();
323 outputDir = Parameters::Get<Parameters::OutputDir>();
327 enableDamarisOutput_ = Parameters::Get<Parameters::EnableDamarisOutput>();
332 msg =
"\nUse of Damaris (command line argument --enable-damaris-output=true) has been disabled for run with only one rank.\n" ;
333 OpmLog::warning(
msg);
334 enableDamarisOutput_ =
false ;
337 if (enableDamarisOutput_) {
340 if (outputDir.empty()) {
355 if (!isSimulationRank_) {
363 outputCout_ = Parameters::Get<Parameters::EnableTerminalOutput>();
367 std::cerr <<
"No input case given. Try '--help' for a usage description.\n";
377 catch (
const std::exception&
e) {
378 if ( mpiRank == 0 ) {
379 std::cerr <<
"Exception received: " <<
e.what() <<
". Try '--help' for a usage description.\n";
393 std::ostringstream
str;
394 Parameters::printValues(
str);
402 Parameters::Get<Parameters::OutputMode>(),
403 !Parameters::Get<Parameters::SchedRestart>(),
404 Parameters::Get<Parameters::EnableLoggingFalloutWarning>(),
405 Parameters::Get<Parameters::ParsingStrictness>(),
406 Parameters::Get<Parameters::ActionParsingStrictness>(),
407 Parameters::Get<Parameters::InputSkipMode>(),
410 Parameters::Get<Parameters::EclOutputInterval>(),
416 catch (
const std::invalid_argument&
e)
419 std::cerr <<
"Failed to create valid EclipseState object." << std::endl;
420 std::cerr <<
"Exception caught: " <<
e.what() << std::endl;
433 void setupVanguard();
443 void handleVersionCmdLine_(
int argc,
char**
argv,
452 void handleTestSplitCommunicatorCmdLine_();
456 if (!
phases.active(Phase::WATER) || (
phases.size() > 2)) {
458 std::cerr <<
"No valid configuration is found for MICP simulation, "
459 <<
"the only valid option is water + MICP\n";
473 const bool diffusive = eclipseState_->getSimulationConfig().isDiffusive();
474 const bool disgasw = eclipseState_->getSimulationConfig().hasDISGASW();
475 const bool vapwat = eclipseState_->getSimulationConfig().hasVAPWAT();
478 if (
phases.active( Phase::OIL ) &&
phases.active( Phase::GAS )) {
487 else if (
phases.active( Phase::OIL ) &&
phases.active( Phase::WATER ) ) {
490 std::cerr <<
"The DIFFUSE option is not available for the two-phase water/oil model." << std::endl;
498 else if (
phases.active( Phase::GAS ) &&
phases.active( Phase::WATER ) ) {
507 std::cerr <<
"The DIFFUSE option is not available for the two-phase gas/water model without disgasw or vapwat." << std::endl;
516 std::cerr <<
"No suitable configuration found, valid are Twophase (oilwater, oilgas and gaswater), polymer, solvent, or blackoil" << std::endl;
525 if (!
phases.active(Phase::WATER)) {
527 std::cerr <<
"No valid configuration is found for polymer simulation, valid options include "
528 <<
"oilwater + polymer and blackoil + polymer" << std::endl;
535 if (
phases.active(Phase::POLYMW)) {
551 return flowFoamMain(argc_, argv_, outputCout_, outputFiles_);
556 if (!
phases.active(Phase::WATER) ||
phases.size() != 1) {
558 std::cerr <<
"No valid configuration is found for water-only simulation, valid options include "
559 <<
"water, water + thermal" << std::endl;
569 if (!
phases.active(Phase::WATER) ||
phases.size() != 2) {
571 std::cerr <<
"No valid configuration is found for water-only simulation, valid options include "
572 <<
"water, water + thermal" << std::endl;
582 if (!
phases.active(Phase::WATER) ||
phases.size() == 2) {
584 std::cerr <<
"No valid configuration is found for brine simulation, valid options include "
585 <<
"oilwater + brine, gaswater + brine and blackoil + brine" << std::endl;
592 if (
phases.active(Phase::OIL)){
595 if (
phases.active(Phase::GAS)){
596 if (eclipseState_->getSimulationConfig().hasPRECSALT() &&
597 eclipseState_->getSimulationConfig().hasVAPWAT()) {
606 else if (eclipseState_->getSimulationConfig().hasPRECSALT()) {
607 if (eclipseState_->getSimulationConfig().hasVAPWAT()) {
616 return flowBrineMain(argc_, argv_, outputCout_, outputFiles_);
624 if (
phases.active(Phase::FOAM)) {
628 if (!
phases.active( Phase::OIL ) &&
phases.active( Phase::WATER ) &&
phases.active( Phase::GAS )) {
633 if (
phases.active( Phase::OIL ) &&
phases.active( Phase::WATER ) &&
phases.active( Phase::GAS )) {
638 std::cerr <<
"No valid configuration is found for solvent simulation, valid options include "
639 <<
"gas + water + solvent and gas + oil + water + solvent" << std::endl;
644 int runExtendedBlackOil()
646 return flowExtboMain(argc_, argv_, outputCout_, outputFiles_);
652 if (!
phases.active( Phase::WATER ) &&
phases.active( Phase::OIL ) &&
phases.active( Phase::GAS )) {
657 if (!
phases.active( Phase::OIL ) &&
phases.active( Phase::WATER ) &&
phases.active( Phase::GAS )) {
659 if (
phases.active(Phase::BRINE)){
670 const bool diffusive = eclipseState_->getSimulationConfig().isDiffusive();
681 const std::string& outputDir,
695 static int getNumThreads()
718 std::cout <<
"Warning: Environment variable OMP_NUM_THREADS takes precedence over the --threads-per-process cmdline argument."
723 std::cout << (
"Warning: Invalid value for OMP_NUM_THREADS environment variable.") << std::endl;
741 char** argv_{
nullptr};
742 bool outputCout_{
false};
743 bool outputFiles_{
false};
747 double setupTime_{0.0};
748 std::string deckFilename_{};
749 std::string flowProgName_{};
750 char *saveArgs_[3]{
nullptr};
751 std::unique_ptr<UDQState> udqState_{};
752 std::unique_ptr<Action::State> actionState_{};
753 std::unique_ptr<WellTestState> wtestState_{};
756 std::shared_ptr<EclipseState> eclipseState_{};
757 std::shared_ptr<Schedule> schedule_{};
758 std::shared_ptr<SummaryConfig> summaryConfig_{};
759 bool mpi_init_{
true};
760 bool mpi_finalize_{
true};
763 bool test_split_comm_ =
false;
764 bool isSimulationRank_ =
true;
766 bool enableDamarisOutput_ =
false;
bool initialize_(int &exitCode, bool keepKeywords=false)
Initialize.
Definition Main.hpp:281