Merge pull request #2728 from blattms/fix-parallel-rebased

Fix parallel ebos
This commit is contained in:
Markus Blatt 2020-08-27 10:54:14 +02:00 committed by GitHub
commit 70805ca1d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 772 additions and 687 deletions

View File

@ -32,6 +32,7 @@ list (APPEND MAIN_SOURCE_FILES
opm/simulators/linalg/FlexibleSolver2.cpp
opm/simulators/linalg/FlexibleSolver3.cpp
opm/simulators/linalg/FlexibleSolver4.cpp
opm/simulators/utils/readDeck.cpp
opm/simulators/timestepping/TimeStepControl.cpp
opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp
opm/simulators/timestepping/SimulatorTimer.cpp
@ -214,6 +215,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/simulators/utils/PropsCentroidsDataHandle.hpp
opm/simulators/wells/PerforationData.hpp
opm/simulators/wells/RateConverter.hpp
opm/simulators/utils/readDeck.hpp
opm/simulators/wells/SimFIBODetails.hpp
opm/simulators/wells/TargetCalculator.hpp
opm/simulators/wells/WellConnectionAuxiliaryModule.hpp

View File

@ -89,18 +89,18 @@ std::unique_ptr<Opm::ParseContext> ebosBlackOilCreateParseContext(int argc, char
return result;
}
void ebosBlackOilSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosBlackOilSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosBlackOilMain(int argc, char **argv)

View File

@ -40,9 +40,9 @@ bool ebosBlackOilDeckFileNameIsSet(int argc, char** argv);
std::string ebosBlackOilGetDeckFileName(int argc, char** argv);
std::unique_ptr<Opm::ParseContext> ebosBlackOilCreateParseContext(int argc, char** argv);
void ebosBlackOilSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosBlackOilSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosBlackOilMain(int argc, char** argv);

View File

@ -41,18 +41,18 @@ SET_BOOL_PROP(EbosBrineTypeTag, EnableBrine, true);
namespace Opm {
void ebosBrineSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
double externalSetupTime)
void ebosBrineSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosBrineTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosBrineMain(int argc, char **argv)

View File

@ -41,18 +41,18 @@ SET_BOOL_PROP(EbosFoamTypeTag, EnableFoam, true);
namespace Opm {
void ebosFoamSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosFoamSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosFoamTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosFoamMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosFoamSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosFoamSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosFoamMain(int argc, char** argv);

View File

@ -57,18 +57,18 @@ public:
namespace Opm {
void ebosGasOilSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosGasOilSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosGasOilTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosGasOilMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosGasOilSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosGasOilSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosGasOilMain(int argc, char** argv);

View File

@ -57,18 +57,18 @@ public:
namespace Opm {
void ebosOilWaterSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosOilWaterSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosOilWaterTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosOilWaterMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosOilWaterSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosOilWaterSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosOilWaterMain(int argc, char** argv);

View File

@ -59,18 +59,18 @@ public:
namespace Opm {
void ebosOilWaterPolymerSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosOilWaterPolymerSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosOilWaterPolymerTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosOilWaterPolymerMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosOilWaterPolymerSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosOilWaterPolymerSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosOilWaterPolymerMain(int argc, char** argv);

View File

@ -41,18 +41,18 @@ SET_BOOL_PROP(EbosPolymerTypeTag, EnablePolymer, true);
namespace Opm {
void ebosPolymerSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosPolymerSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosPolymerTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosPolymerMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosPolymerSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosPolymerSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosPolymerMain(int argc, char** argv);

View File

@ -41,18 +41,18 @@ SET_BOOL_PROP(EbosSolventTypeTag, EnableSolvent, true);
namespace Opm {
void ebosSolventSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosSolventSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosSolventTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosSolventMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosSolventSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosSolventSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosSolventMain(int argc, char** argv);

View File

@ -41,18 +41,18 @@ SET_BOOL_PROP(EbosThermalTypeTag, EnableEnergy, true);
namespace Opm {
void ebosThermalSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosThermalSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime)
{
using ProblemTypeTag = Properties::TTag::EbosThermalTypeTag;
using Vanguard = GetPropType<ProblemTypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(externalSetupTime);
Vanguard::setExternalParseContext(parseContext);
Vanguard::setExternalErrorGuard(errorGuard);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalParseContext(std::move(parseContext));
Vanguard::setExternalErrorGuard(std::move(errorGuard));
Vanguard::setExternalDeck(std::move(deck));
}
int ebosThermalMain(int argc, char **argv)

View File

@ -33,9 +33,9 @@
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
namespace Opm {
void ebosThermalSetDeck(Opm::Deck* deck,
Opm::ParseContext* parseContext,
Opm::ErrorGuard* errorGuard,
void ebosThermalSetDeck(std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::ParseContext> parseContext,
std::unique_ptr<Opm::ErrorGuard> errorGuard,
double externalSetupTime);
int ebosThermalMain(int argc, char** argv);

View File

@ -49,6 +49,7 @@
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/simulators/utils/readDeck.hpp>
#if HAVE_MPI
#include <mpi.h>
@ -223,14 +224,14 @@ public:
/*!
* \brief Set the Opm::ParseContext object which ought to be used for parsing the deck and creating the Opm::EclipseState object.
*/
static void setExternalParseContext(Opm::ParseContext* parseContext)
{ externalParseContext_ = parseContext; }
static void setExternalParseContext(std::unique_ptr<Opm::ParseContext> parseContext)
{ externalParseContext_ = std::move(parseContext); }
/*!
* \brief Set the Opm::ErrorGuard object which ought to be used for parsing the deck and creating the Opm::EclipseState object.
*/
static void setExternalErrorGuard(Opm::ErrorGuard* errorGuard)
{ externalErrorGuard_ = errorGuard; }
static void setExternalErrorGuard(std::unique_ptr<Opm::ErrorGuard> errorGuard)
{ externalErrorGuard_ = std::move(errorGuard); }
/*!
* \brief Set the Opm::Deck object which ought to be used when the simulator vanguard
@ -242,14 +243,14 @@ public:
* management of these two objects, i.e., they are not allowed to be deleted as long
* as the simulator vanguard object is alive.
*/
static void setExternalDeck(Opm::Deck* deck)
{ externalDeck_ = deck; externalDeckSet_ = true; }
static void setExternalDeck(std::unique_ptr<Opm::Deck> deck)
{ externalDeck_ = std::move(deck); externalDeckSet_ = true; }
/*!
* \brief Set the Opm::EclipseState object which ought to be used when the simulator
* vanguard is instantiated.
*/
static void setExternalEclState(Opm::EclipseState* eclState)
{ externalEclState_ = eclState; }
static void setExternalEclState(std::unique_ptr<Opm::EclipseState> eclState)
{ externalEclState_ = std::move(eclState); }
/*!
* \brief Create the grid for problem data files which use the ECL file format.
@ -300,81 +301,47 @@ public:
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
}
// create the parser objects for the deck or use their externally specified
// versions (if desired)
if (!externalParseContext_) {
internalParseContext_ = createParseContext();
parseContext_ = internalParseContext_.get();
std::unique_ptr<ErrorGuard> errorGuard = nullptr;
// Check that we are in one of the known configurations for external variables
// and move them to internal
if (externalDeck_)
{
deck_ = std::move(externalDeck_);
if (externalParseContext_ && externalErrorGuard_ )
{
parseContext_ = std::move(externalParseContext_);
errorGuard = std::move(externalErrorGuard_);
}
else if(externalEclState_ && externalEclSchedule_ && externalEclSummaryConfig_)
{
eclState_ = std::move(externalEclState_);
eclSchedule_ = std::move(externalEclSchedule_);
eclSummaryConfig_ = std::move(externalEclSummaryConfig_);
}
else
{
OPM_THROW(std::logic_error, "Either parse context and error guard or ECL state, schedule, and summary config need to be"
<< " set externally.");
}
}
else if (externalParseContext_)
{
parseContext_ = std::move(externalParseContext_);
}
else
parseContext_ = externalParseContext_;
if (!externalParseContext_) {
internalErrorGuard_.reset(new Opm::ErrorGuard);
errorGuard_ = internalErrorGuard_.get();
}
else
errorGuard_ = externalErrorGuard_;
if (!externalDeck_ && !externalDeckSet_) {
if (myRank == 0)
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
Opm::Parser parser;
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName, *parseContext_, *errorGuard_)));
deck_ = internalDeck_.get();
if (enableExperiments && myRank == 0)
Opm::checkDeck(*deck_, parser, *parseContext_, *errorGuard_);
}
else {
deck_ = externalDeck_;
{
parseContext_ = createParseContext();
}
if (!externalEclState_) {
internalEclState_.reset(new Opm::EclipseState(*deck_));
eclState_ = internalEclState_.get();
}
else {
assert(externalEclState_);
readDeck(myRank, fileName, deck_, eclState_, eclSchedule_,
eclSummaryConfig_, std::move(errorGuard), python,
std::move(parseContext_), /* initFromRestart = */ false,
/* checkDeck = */ enableExperiments);
deck_ = externalDeck_;
eclState_ = externalEclState_;
}
if (!externalEclSchedule_) {
// create the schedule object. Note that if eclState is supposed to represent
// the internalized version of the deck, this constitutes a layering
// violation.
internalEclSchedule_.reset(new Opm::Schedule(*deck_, *eclState_, *parseContext_, *errorGuard_, python));
eclSchedule_ = internalEclSchedule_.get();
}
else
eclSchedule_ = externalEclSchedule_;
this->summaryState_.reset( new Opm::SummaryState( std::chrono::system_clock::from_time_t(this->eclSchedule_->getStartTime() )));
this->actionState_.reset( new Opm::Action::State() );
if (!externalEclSummaryConfig_) {
// create the schedule object. Note that if eclState is supposed to represent
// the internalized version of the deck, this constitutes a layering
// violation.
internalEclSummaryConfig_.reset(new Opm::SummaryConfig(*deck_,
*eclSchedule_,
eclState_->getTableManager(),
*parseContext_,
*errorGuard_));
eclSummaryConfig_ = internalEclSummaryConfig_.get();
}
else
eclSummaryConfig_ = externalEclSummaryConfig_;
if (*errorGuard_) {
errorGuard_->dump();
errorGuard_->clear();
throw std::runtime_error("Unrecoverable errors were encountered while loading input.");
}
this->summaryState_ = std::make_unique<Opm::SummaryState>( std::chrono::system_clock::from_time_t(this->eclSchedule_->getStartTime() ));
this->actionState_ = std::make_unique<Opm::Action::State>() ;
// Possibly override IOConfig setting for how often RESTART files should get
// written to disk (every N report step)
@ -416,8 +383,8 @@ public:
* The lifetime of this object is not managed by the vanguard, i.e., the object must
* stay valid until after the vanguard gets destroyed.
*/
static void setExternalSchedule(Opm::Schedule* schedule)
{ externalEclSchedule_ = schedule; }
static void setExternalSchedule(std::unique_ptr<Opm::Schedule> schedule)
{ externalEclSchedule_ = std::move(schedule); }
/*!
* \brief Return a reference to the object that determines which quantities ought to
@ -432,8 +399,8 @@ public:
* The lifetime of this object is not managed by the vanguard, i.e., the object must
* stay valid until after the vanguard gets destroyed.
*/
static void setExternalSummaryConfig(Opm::SummaryConfig* summaryConfig)
{ externalEclSummaryConfig_ = summaryConfig; }
static void setExternalSummaryConfig(std::unique_ptr<Opm::SummaryConfig> summaryConfig)
{ externalEclSummaryConfig_ = std::move(summaryConfig); }
/*!
@ -573,8 +540,11 @@ protected:
asImp_().finalizeInit_();
if (enableExperiments) {
Opm::RelpermDiagnostics relpermDiagnostics;
relpermDiagnostics.diagnosis(*eclState_, asImp_().grid());
if (asImp_().grid().size(0)) //grid not loadbalanced yet for ebos!
{
Opm::RelpermDiagnostics relpermDiagnostics;
relpermDiagnostics.diagnosis(*eclState_, asImp_().grid());
}
}
}
private:
@ -616,31 +586,25 @@ private:
static Scalar externalSetupTime_;
static Opm::ParseContext* externalParseContext_;
static Opm::ErrorGuard* externalErrorGuard_;
static Opm::Deck* externalDeck_;
static std::unique_ptr<Opm::ParseContext> externalParseContext_;
static std::unique_ptr<Opm::ErrorGuard> externalErrorGuard_;
static std::unique_ptr<Opm::Deck> externalDeck_;
static bool externalDeckSet_;
static Opm::EclipseState* externalEclState_;
static Opm::Schedule* externalEclSchedule_;
static Opm::SummaryConfig* externalEclSummaryConfig_;
static std::unique_ptr<Opm::EclipseState> externalEclState_;
static std::unique_ptr<Opm::Schedule> externalEclSchedule_;
static std::unique_ptr<Opm::SummaryConfig> externalEclSummaryConfig_;
std::unique_ptr<Opm::ParseContext> internalParseContext_;
std::unique_ptr<Opm::ErrorGuard> internalErrorGuard_;
std::unique_ptr<Opm::Deck> internalDeck_;
std::unique_ptr<Opm::EclipseState> internalEclState_;
std::unique_ptr<Opm::Schedule> internalEclSchedule_;
std::unique_ptr<Opm::SummaryConfig> internalEclSummaryConfig_;
std::unique_ptr<Opm::SummaryState> summaryState_;
std::unique_ptr<Opm::Action::State> actionState_;
// these attributes point either to the internal or to the external version of the
// parser objects.
Opm::ParseContext* parseContext_;
Opm::ErrorGuard* errorGuard_;
Opm::Deck* deck_;
Opm::EclipseState* eclState_;
Opm::Schedule* eclSchedule_;
Opm::SummaryConfig* eclSummaryConfig_;
std::unique_ptr<Opm::ParseContext> parseContext_;
std::unique_ptr<Opm::ErrorGuard> errorGuard_;
std::unique_ptr<Opm::Deck> deck_;
std::unique_ptr<Opm::EclipseState> eclState_;
std::unique_ptr<Opm::Schedule> eclSchedule_;
std::unique_ptr<Opm::SummaryConfig> eclSummaryConfig_;
std::shared_ptr<Opm::Python> python = std::make_shared<Opm::Python>();
Dune::EdgeWeightMethod edgeWeightsMethod_;
@ -657,25 +621,25 @@ template <class TypeTag>
typename EclBaseVanguard<TypeTag>::Scalar EclBaseVanguard<TypeTag>::externalSetupTime_ = 0.0;
template <class TypeTag>
Opm::ParseContext* EclBaseVanguard<TypeTag>::externalParseContext_ = nullptr;
std::unique_ptr<Opm::ParseContext> EclBaseVanguard<TypeTag>::externalParseContext_ = nullptr;
template <class TypeTag>
Opm::ErrorGuard* EclBaseVanguard<TypeTag>::externalErrorGuard_ = nullptr;
std::unique_ptr<Opm::ErrorGuard> EclBaseVanguard<TypeTag>::externalErrorGuard_ = nullptr;
template <class TypeTag>
Opm::Deck* EclBaseVanguard<TypeTag>::externalDeck_ = nullptr;
std::unique_ptr<Opm::Deck> EclBaseVanguard<TypeTag>::externalDeck_ = nullptr;
template <class TypeTag>
bool EclBaseVanguard<TypeTag>::externalDeckSet_ = false;
template <class TypeTag>
Opm::EclipseState* EclBaseVanguard<TypeTag>::externalEclState_;
std::unique_ptr<Opm::EclipseState> EclBaseVanguard<TypeTag>::externalEclState_;
template <class TypeTag>
Opm::Schedule* EclBaseVanguard<TypeTag>::externalEclSchedule_ = nullptr;
std::unique_ptr<Opm::Schedule> EclBaseVanguard<TypeTag>::externalEclSchedule_ = nullptr;
template <class TypeTag>
Opm::SummaryConfig* EclBaseVanguard<TypeTag>::externalEclSummaryConfig_ = nullptr;
std::unique_ptr<Opm::SummaryConfig> EclBaseVanguard<TypeTag>::externalEclSummaryConfig_ = nullptr;
} // namespace Opm

View File

@ -98,6 +98,7 @@
#include <dune/common/version.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/parallel/mpiguard.hh>
#include <opm/output/eclipse/EclipseIO.hpp>
@ -1913,58 +1914,65 @@ public:
private:
void checkDeckCompatibility_() const
{
const auto& deck = this->simulator().vanguard().deck();
const auto& comm = this->simulator().gridView().comm();
bool beVerbose = comm.rank() == 0;
Dune::MPIGuard guard;
if (enableApiTracking)
throw std::logic_error("API tracking is not yet implemented but requested at compile time.");
if (!enableApiTracking && deck.hasKeyword("API"))
throw std::logic_error("The simulator is build with API tracking disabled, but API tracking is requested by the deck.");
if (comm.rank() == 0)
{
// Only rank 0 has the deck and hence can do the checks!
const auto& deck = this->simulator().vanguard().deck();
if (enableSolvent && !deck.hasKeyword("SOLVENT"))
throw std::runtime_error("The simulator requires the solvent option to be enabled, but the deck does not.");
else if (!enableSolvent && deck.hasKeyword("SOLVENT"))
throw std::runtime_error("The deck enables the solvent option, but the simulator is compiled without it.");
if (enableApiTracking)
throw std::logic_error("API tracking is not yet implemented but requested at compile time.");
if (!enableApiTracking && deck.hasKeyword("API"))
throw std::logic_error("The simulator is build with API tracking disabled, but API tracking is requested by the deck.");
if (enablePolymer && !deck.hasKeyword("POLYMER"))
throw std::runtime_error("The simulator requires the polymer option to be enabled, but the deck does not.");
else if (!enablePolymer && deck.hasKeyword("POLYMER"))
throw std::runtime_error("The deck enables the polymer option, but the simulator is compiled without it.");
if (enableSolvent && !deck.hasKeyword("SOLVENT"))
throw std::runtime_error("The simulator requires the solvent option to be enabled, but the deck does not.");
else if (!enableSolvent && deck.hasKeyword("SOLVENT"))
throw std::runtime_error("The deck enables the solvent option, but the simulator is compiled without it.");
if (deck.hasKeyword("TEMP") && deck.hasKeyword("THERMAL"))
throw std::runtime_error("The deck enables both, the TEMP and the THERMAL options, but they are mutually exclusive.");
if (enablePolymer && !deck.hasKeyword("POLYMER"))
throw std::runtime_error("The simulator requires the polymer option to be enabled, but the deck does not.");
else if (!enablePolymer && deck.hasKeyword("POLYMER"))
throw std::runtime_error("The deck enables the polymer option, but the simulator is compiled without it.");
bool deckEnergyEnabled = (deck.hasKeyword("TEMP") || deck.hasKeyword("THERMAL"));
if (enableEnergy && !deckEnergyEnabled)
throw std::runtime_error("The simulator requires the TEMP or the THERMAL option to be enabled, but the deck activates neither.");
else if (!enableEnergy && deckEnergyEnabled)
throw std::runtime_error("The deck enables the TEMP or the THERMAL option, but the simulator is not compiled to support either.");
if (deck.hasKeyword("TEMP") && deck.hasKeyword("THERMAL"))
throw std::runtime_error("The deck enables both, the TEMP and the THERMAL options, but they are mutually exclusive.");
if (deckEnergyEnabled && deck.hasKeyword("TEMP") && beVerbose)
std::cerr << "WARNING: The deck requests the TEMP option, i.e., treating energy "
<< "conservation as a post processing step. This is currently unsupported, "
<< "i.e., energy conservation is always handled fully implicitly." << std::endl;
bool deckEnergyEnabled = (deck.hasKeyword("TEMP") || deck.hasKeyword("THERMAL"));
if (enableEnergy && !deckEnergyEnabled)
throw std::runtime_error("The simulator requires the TEMP or the THERMAL option to be enabled, but the deck activates neither.");
else if (!enableEnergy && deckEnergyEnabled)
throw std::runtime_error("The deck enables the TEMP or the THERMAL option, but the simulator is not compiled to support either.");
int numDeckPhases = FluidSystem::numActivePhases();
if (numDeckPhases < Indices::numPhases && beVerbose)
std::cerr << "WARNING: The number of active phases specified by the deck ("
<< numDeckPhases << ") is smaller than the number of compiled-in phases ("
<< Indices::numPhases << "). This usually results in a significant "
<< "performance degradation compared to using a specialized simulator." << std::endl;
else if (numDeckPhases < Indices::numPhases)
throw std::runtime_error("The deck enables "+std::to_string(numDeckPhases)+" phases "
"while this simulator can only handle "+
std::to_string(Indices::numPhases)+".");
if (deckEnergyEnabled && deck.hasKeyword("TEMP"))
std::cerr << "WARNING: The deck requests the TEMP option, i.e., treating energy "
<< "conservation as a post processing step. This is currently unsupported, "
<< "i.e., energy conservation is always handled fully implicitly." << std::endl;
// make sure that the correct phases are active
if (FluidSystem::phaseIsActive(oilPhaseIdx) && !Indices::oilEnabled)
throw std::runtime_error("The deck enables oil, but this simulator cannot handle it.");
if (FluidSystem::phaseIsActive(gasPhaseIdx) && !Indices::gasEnabled)
throw std::runtime_error("The deck enables gas, but this simulator cannot handle it.");
if (FluidSystem::phaseIsActive(waterPhaseIdx) && !Indices::waterEnabled)
throw std::runtime_error("The deck enables water, but this simulator cannot handle it.");
// the opposite cases should be fine (albeit a bit slower than what's possible)
int numDeckPhases = FluidSystem::numActivePhases();
if (numDeckPhases < Indices::numPhases)
std::cerr << "WARNING: The number of active phases specified by the deck ("
<< numDeckPhases << ") is smaller than the number of compiled-in phases ("
<< Indices::numPhases << "). This usually results in a significant "
<< "performance degradation compared to using a specialized simulator." << std::endl;
else if (numDeckPhases < Indices::numPhases)
throw std::runtime_error("The deck enables "+std::to_string(numDeckPhases)+" phases "
"while this simulator can only handle "+
std::to_string(Indices::numPhases)+".");
// make sure that the correct phases are active
if (FluidSystem::phaseIsActive(oilPhaseIdx) && !Indices::oilEnabled)
throw std::runtime_error("The deck enables oil, but this simulator cannot handle it.");
if (FluidSystem::phaseIsActive(gasPhaseIdx) && !Indices::gasEnabled)
throw std::runtime_error("The deck enables gas, but this simulator cannot handle it.");
if (FluidSystem::phaseIsActive(waterPhaseIdx) && !Indices::waterEnabled)
throw std::runtime_error("The deck enables water, but this simulator cannot handle it.");
// the opposite cases should be fine (albeit a bit slower than what's possible)
}
// throws an expeption on all processes if rank 0 had a problem
guard.finalize();
}
bool drsdtActive_() const

View File

@ -123,9 +123,9 @@ int main(int argc, char **argv)
if (polymerActive && oilActive && waterActive) {
if (myRank == 0)
std::cout << "Using oil-water-polymer mode" << std::endl;
Opm::ebosOilWaterPolymerSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosOilWaterPolymerSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosOilWaterPolymerMain(argc, argv);
}
@ -154,9 +154,9 @@ int main(int argc, char **argv)
if (oilActive && waterActive) {
if (myRank == 0)
std::cout << "Using oil-water mode" << std::endl;
Opm::ebosOilWaterSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosOilWaterSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosOilWaterMain(argc, argv);
}
@ -164,9 +164,9 @@ int main(int argc, char **argv)
// run ebos_gasoil
if (myRank == 0)
std::cout << "Using gas-oil mode" << std::endl;
Opm::ebosGasOilSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosGasOilSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosGasOilMain(argc, argv);
}
@ -202,9 +202,9 @@ int main(int argc, char **argv)
// run ebos_foam
if (myRank == 0)
std::cout << "Using foam mode" << std::endl;
Opm::ebosFoamSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosFoamSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosFoamMain(argc, argv);
}
@ -233,9 +233,9 @@ int main(int argc, char **argv)
// run ebos_polymer
if (myRank == 0)
std::cout << "Using polymer mode" << std::endl;
Opm::ebosPolymerSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosPolymerSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosPolymerMain(argc, argv);
}
@ -264,9 +264,9 @@ int main(int argc, char **argv)
// run ebos_solvent
if (myRank == 0)
std::cout << "Using solvent mode" << std::endl;
Opm::ebosSolventSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosSolventSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosSolventMain(argc, argv);
}
@ -295,18 +295,18 @@ int main(int argc, char **argv)
// run ebos_thermal
if (myRank == 0)
std::cout << "Using thermal mode" << std::endl;
Opm::ebosThermalSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosThermalSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosThermalMain(argc, argv);
}
else {
if (myRank == 0)
std::cout << "Using blackoil mode" << std::endl;
Opm::ebosBlackOilSetDeck(deck.get(),
parseContext.get(),
errorGuard.get(),
Opm::ebosBlackOilSetDeck(std::move(deck),
std::move(parseContext),
std::move(errorGuard),
externalSetupTimer.elapsed());
return Opm::ebosBlackOilMain(argc, argv);
}

View File

@ -42,112 +42,11 @@
#include <opm/common/utility/String.hpp>
#include <opm/simulators/flow/Main.hpp>
//! \cond SKIP_THIS
namespace Opm {
enum class FileOutputMode {
//! \brief No output to files.
OUTPUT_NONE = 0,
//! \brief Output only to log files, no eclipse output.
OUTPUT_LOG_ONLY = 1,
//! \brief Output to all files.
OUTPUT_ALL = 3
};
static void ensureOutputDirExists(const std::string& cmdline_output_dir)
{
if (!Opm::filesystem::is_directory(cmdline_output_dir)) {
try {
Opm::filesystem::create_directories(cmdline_output_dir);
}
catch (...) {
throw std::runtime_error("Creation of output directory '" + cmdline_output_dir + "' failed\n");
}
}
}
// Setup the OpmLog backends
static FileOutputMode setupLogging(int mpi_rank_, const std::string& deck_filename, const std::string& cmdline_output_dir, const std::string& cmdline_output, bool output_cout_, const std::string& stdout_log_id) {
if (!cmdline_output_dir.empty()) {
ensureOutputDirExists(cmdline_output_dir);
}
// create logFile
using Opm::filesystem::path;
path fpath(deck_filename);
std::string baseName;
std::ostringstream debugFileStream;
std::ostringstream logFileStream;
// Strip extension "." or ".DATA"
std::string extension = uppercase(fpath.extension().string());
if (extension == ".DATA" || extension == ".") {
baseName = uppercase(fpath.stem().string());
} else {
baseName = uppercase(fpath.filename().string());
}
std::string output_dir = cmdline_output_dir;
if (output_dir.empty()) {
output_dir = absolute(path(baseName).parent_path()).string();
}
logFileStream << output_dir << "/" << baseName;
debugFileStream << output_dir << "/" << baseName;
if (mpi_rank_ != 0) {
// Added rank to log file for non-zero ranks.
// This prevents message loss.
debugFileStream << "." << mpi_rank_;
// If the following file appears then there is a bug.
logFileStream << "." << mpi_rank_;
}
logFileStream << ".PRT";
debugFileStream << ".DBG";
FileOutputMode output;
{
static std::map<std::string, FileOutputMode> stringToOutputMode =
{ {"none", FileOutputMode::OUTPUT_NONE },
{"false", FileOutputMode::OUTPUT_LOG_ONLY },
{"log", FileOutputMode::OUTPUT_LOG_ONLY },
{"all" , FileOutputMode::OUTPUT_ALL },
{"true" , FileOutputMode::OUTPUT_ALL }};
auto outputModeIt = stringToOutputMode.find(cmdline_output);
if (outputModeIt != stringToOutputMode.end()) {
output = outputModeIt->second;
}
else {
output = FileOutputMode::OUTPUT_ALL;
std::cerr << "Value " << cmdline_output <<
" is not a recognized output mode. Using \"all\" instead."
<< std::endl;
}
}
if (output > FileOutputMode::OUTPUT_NONE) {
std::shared_ptr<Opm::EclipsePRTLog> prtLog = std::make_shared<Opm::EclipsePRTLog>(logFileStream.str(), Opm::Log::NoDebugMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("ECLIPSEPRTLOG", prtLog);
prtLog->setMessageLimiter(std::make_shared<Opm::MessageLimiter>());
prtLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(false));
}
if (output >= FileOutputMode::OUTPUT_LOG_ONLY) {
std::string debugFile = debugFileStream.str();
std::shared_ptr<Opm::StreamLog> debugLog = std::make_shared<Opm::EclipsePRTLog>(debugFileStream.str(), Opm::Log::DefaultMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("DEBUGLOG", debugLog);
}
std::shared_ptr<Opm::StreamLog> streamLog = std::make_shared<Opm::StreamLog>(std::cout, Opm::Log::StdoutMessageTypes);
Opm::OpmLog::addBackend(stdout_log_id, streamLog);
streamLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(true));
return output;
}
//! \endcond
/*!

View File

@ -34,16 +34,19 @@
namespace Opm {
void flowEbosBlackoilSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosBlackoilSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
std::unique_ptr<Opm::FlowMainEbos<Properties::TTag::EclFlowProblem>>

View File

@ -24,7 +24,10 @@
#include <opm/simulators/flow/FlowMainEbos.hpp>
namespace Opm {
void flowEbosBlackoilSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosBlackoilSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles);

View File

@ -36,16 +36,19 @@ SET_BOOL_PROP(EclFlowBrineProblem, EnableBrine, true);
}}
namespace Opm {
void flowEbosBrineSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosBrineSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowBrineProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}

View File

@ -24,7 +24,10 @@
namespace Opm {
void flowEbosBrineSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosBrineSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosBrineMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -36,16 +36,19 @@ SET_BOOL_PROP(EclFlowEnergyProblem, EnableEnergy, true);
}}
namespace Opm {
void flowEbosEnergySetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosEnergySetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowEnergyProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosEnergySetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosEnergySetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -36,16 +36,19 @@ SET_BOOL_PROP(EclFlowFoamProblem, EnableFoam, true);
}}
namespace Opm {
void flowEbosFoamSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosFoamSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowFoamProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}

View File

@ -24,7 +24,10 @@
namespace Opm {
void flowEbosFoamSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosFoamSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosFoamMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -60,16 +60,19 @@ public:
}}
namespace Opm {
void flowEbosGasOilSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosGasOilSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowGasOilProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosGasOilSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosGasOilSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosGasOilMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -60,16 +60,19 @@ public:
}}
namespace Opm {
void flowEbosOilWaterSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosOilWaterSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowOilWaterProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosOilWaterSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosOilWaterSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -60,16 +60,19 @@ public:
}}
namespace Opm {
void flowEbosOilWaterBrineSetDeck(double setupTime, Deck* deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosOilWaterBrineSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowOilWaterBrineProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosOilWaterBrineSetDeck(double setupTime, Deck* deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosOilWaterBrineSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosOilWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -61,16 +61,19 @@ public:
}}
namespace Opm {
void flowEbosOilWaterPolymerSetDeck(double setupTime, Deck* deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosOilWaterPolymerSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowOilWaterPolymerProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosOilWaterPolymerSetDeck(double setupTime, Deck* deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosOilWaterPolymerSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosOilWaterPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -68,7 +68,7 @@ namespace Opm {
using TypeTag = Properties::TTag::EclFlowOilWaterPolymerInjectivityProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalDeck(&deck, &eclState);
Vanguard::setExternalDeck(std::move(deck, &eclState));
} */
// ----------------- Main program -----------------

View File

@ -36,16 +36,19 @@ SET_BOOL_PROP(EclFlowPolymerProblem, EnablePolymer, true);
}}
namespace Opm {
void flowEbosPolymerSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosPolymerSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowPolymerProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------

View File

@ -23,7 +23,10 @@
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
namespace Opm {
void flowEbosPolymerSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosPolymerSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles);
}

View File

@ -36,16 +36,19 @@ SET_BOOL_PROP(EclFlowSolventProblem, EnableSolvent, true);
}}
namespace Opm {
void flowEbosSolventSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosSolventSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig)
{
using TypeTag = Properties::TTag::EclFlowSolventProblem;
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalSetupTime(setupTime);
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}

View File

@ -24,7 +24,10 @@
namespace Opm {
void flowEbosSolventSetDeck(double setupTime, Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig);
void flowEbosSolventSetDeck(double setupTime, std::unique_ptr<Deck> deck,
std::unique_ptr<EclipseState> eclState,
std::unique_ptr<Schedule> schedule,
std::unique_ptr<SummaryConfig> summaryConfig);
int flowEbosSolventMain(int argc, char** argv, bool outoutCout, bool outputFiles);
}

View File

@ -37,10 +37,6 @@
# include <flow/flow_ebos_oilwater_polymer_injectivity.hpp>
# endif
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
@ -51,8 +47,7 @@
#include <opm/models/utils/parametersystem.hh>
#include <opm/simulators/flow/FlowMainEbos.hpp>
#include <opm/simulators/flow/MissingFeatures.hpp>
#include <opm/simulators/utils/readDeck.hpp>
#if HAVE_DUNE_FEM
#include <dune/fem/misc/mpimanager.hh>
@ -78,13 +73,13 @@ NEW_TYPE_TAG(FlowEarlyBird, INHERITS_FROM(EclFlowProblem));
namespace Opm {
template <class TypeTag>
void flowEbosSetDeck(Deck *deck, EclipseState& eclState, Schedule& schedule, SummaryConfig& summaryConfig)
void flowEbosSetDeck(std::unique_ptr<Deck> deck, std::unique_ptr<EclipseState> eclState, std::unique_ptr<Schedule> schedule, std::unique_ptr<SummaryConfig> summaryConfig)
{
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
Vanguard::setExternalDeck(deck);
Vanguard::setExternalEclState(&eclState);
Vanguard::setExternalSchedule(&schedule);
Vanguard::setExternalSummaryConfig(&summaryConfig);
Vanguard::setExternalDeck(std::move(deck));
Vanguard::setExternalEclState(std::move(eclState));
Vanguard::setExternalSchedule(std::move(schedule));
Vanguard::setExternalSummaryConfig(std::move(summaryConfig));
}
// ----------------- Main program -----------------
@ -108,6 +103,7 @@ namespace Opm {
namespace Opm
{
// ----------------- Main class -----------------
// For now, we will either be instantiated from main() in flow.cpp,
// or from a Python pybind11 module..
@ -120,14 +116,6 @@ namespace Opm
private:
using FlowMainEbosType = Opm::FlowMainEbos<Opm::Properties::TTag::EclFlowProblem>;
enum class FileOutputMode {
//! \brief No output to files.
OUTPUT_NONE = 0,
//! \brief Output only to log files, no eclipse output.
OUTPUT_LOG_ONLY = 1,
//! \brief Output to all files.
OUTPUT_ALL = 3
};
public:
Main(int argc, char** argv) : argc_(argc), argv_(argv) { }
@ -143,16 +131,16 @@ namespace Opm
Main(int argc,
char** argv,
std::shared_ptr<Opm::Deck> deck,
std::shared_ptr<Opm::EclipseState> eclipseState,
std::shared_ptr<Opm::Schedule> schedule,
std::shared_ptr<Opm::SummaryConfig> summaryConfig)
std::unique_ptr<Opm::Deck> deck,
std::unique_ptr<Opm::EclipseState> eclipseState,
std::unique_ptr<Opm::Schedule> schedule,
std::unique_ptr<Opm::SummaryConfig> summaryConfig)
: argc_(argc)
, argv_(argv)
, deck_(deck)
, eclipseState_(eclipseState)
, schedule_(schedule)
, summaryConfig_(summaryConfig)
, deck_(std::move(deck))
, eclipseState_(std::move(eclipseState))
, schedule_(std::move(schedule))
, summaryConfig_(std::move(summaryConfig))
{
}
@ -189,10 +177,10 @@ namespace Opm
// case. E.g. check that number of phases == 3
Opm::flowEbosBlackoilSetDeck(
setupTime_,
deck_.get(),
*eclipseState_,
*schedule_,
*summaryConfig_);
std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosBlackoilMainInit(
argc_, argv_, outputCout_, outputFiles_);
} else {
@ -216,12 +204,13 @@ namespace Opm
else if( phases.size() == 2 ) {
// oil-gas
if (phases.active( Opm::Phase::GAS )) {
Opm::flowEbosGasOilSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosGasOilSetDeck(setupTime_, std::move(deck_), std::move(eclipseState_),
std::move(schedule_), std::move(summaryConfig_));
return Opm::flowEbosGasOilMain(argc_, argv_, outputCout_, outputFiles_);
}
// oil-water
else if ( phases.active( Opm::Phase::WATER ) ) {
Opm::flowEbosOilWaterSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosOilWaterSetDeck(setupTime_, std::move(deck_), std::move(eclipseState_), std::move(schedule_), std::move(summaryConfig_));
return Opm::flowEbosOilWaterMain(argc_, argv_, outputCout_, outputFiles_);
}
else {
@ -248,16 +237,25 @@ namespace Opm
}
if ( phases.size() == 3 ) { // oil water polymer case
Opm::flowEbosOilWaterPolymerSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosOilWaterPolymerSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosOilWaterPolymerMain(argc_, argv_, outputCout_, outputFiles_);
} else {
Opm::flowEbosPolymerSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosPolymerSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosPolymerMain(argc_, argv_, outputCout_, outputFiles_);
}
}
// Foam case
else if ( phases.active( Opm::Phase::FOAM ) ) {
Opm::flowEbosFoamSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosFoamSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosFoamMain(argc_, argv_, outputCout_, outputFiles_);
}
// Brine case
@ -269,27 +267,42 @@ namespace Opm
return EXIT_FAILURE;
}
if ( phases.size() == 3 ) { // oil water brine case
Opm::flowEbosOilWaterBrineSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosOilWaterBrineSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosOilWaterBrineMain(argc_, argv_, outputCout_, outputFiles_);
} else {
Opm::flowEbosBrineSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosBrineSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosBrineMain(argc_, argv_, outputCout_, outputFiles_);
}
}
// Solvent case
else if ( phases.active( Opm::Phase::SOLVENT ) ) {
Opm::flowEbosSolventSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosSolventSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosSolventMain(argc_, argv_, outputCout_, outputFiles_);
}
// Energy case
else if (eclipseState_->getSimulationConfig().isThermal()) {
Opm::flowEbosEnergySetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosEnergySetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosEnergyMain(argc_, argv_, outputCout_, outputFiles_);
}
#endif // FLOW_BLACKOIL_ONLY
// Blackoil case
else if( phases.size() == 3 ) {
Opm::flowEbosBlackoilSetDeck(setupTime_, deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosBlackoilSetDeck(setupTime_, std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosBlackoilMain(argc_, argv_, outputCout_, outputFiles_);
}
else {
@ -302,7 +315,10 @@ namespace Opm
template <class TypeTag>
int dispatchStatic_()
{
Opm::flowEbosSetDeck<TypeTag>(deck_.get(), *eclipseState_, *schedule_, *summaryConfig_);
Opm::flowEbosSetDeck<TypeTag>(std::move(deck_),
std::move(eclipseState_),
std::move(schedule_),
std::move(summaryConfig_));
return Opm::flowEbosMain<TypeTag>(argc_, argv_, outputCout_, outputFiles_);
}
@ -392,117 +408,30 @@ namespace Opm
Opm::FlowMainEbos<PreTypeTag>::printBanner();
}
// Create Deck and EclipseState.
if (outputCout_) {
std::cout << "Reading deck file '" << deckFilename << "'\n";
std::cout.flush();
}
try {
if (outputCout_) {
std::cout << "Reading deck file '" << deckFilename << "'\n";
std::cout.flush();
}
auto python = std::make_shared<Opm::Python>();
{
Opm::Parser parser;
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
Opm::ErrorGuard errorGuard;
if (outputDir.empty())
outputDir = EWOMS_GET_PARAM(PreTypeTag, std::string, OutputDir);
outputMode = setupLogging_(mpiRank,
deckFilename,
outputDir,
EWOMS_GET_PARAM(PreTypeTag, std::string, OutputMode),
outputCout_, "STDOUT_LOGGER");
const bool init_from_restart_file = !EWOMS_GET_PARAM(PreTypeTag, bool, SchedRestart);
if (outputDir.empty())
outputDir = EWOMS_GET_PARAM(PreTypeTag, std::string, OutputDir);
outputMode = setupLogging(mpiRank,
deckFilename,
outputDir,
EWOMS_GET_PARAM(PreTypeTag, std::string, OutputMode),
outputCout_, "STDOUT_LOGGER");
auto parseContext =
std::make_unique<Opm::ParseContext>(std::vector<std::pair<std::string , InputError::Action>>
{{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
if (EWOMS_GET_PARAM(PreTypeTag, bool, EclStrictParsing))
parseContext.update( Opm::InputError::DELAYED_EXIT1);
Opm::FlowMainEbos<PreTypeTag>::printPRTHeader(outputCout_);
#if HAVE_MPI
int parseSuccess = 0;
#endif
std::string failureMessage;
if (mpiRank == 0) {
try
{
if (!deck_)
deck_.reset( new Opm::Deck( parser.parseFile(deckFilename , parseContext, errorGuard)));
Opm::MissingFeatures::checkKeywords(*deck_, parseContext, errorGuard);
if ( outputCout_ )
Opm::checkDeck(*deck_, parser, parseContext, errorGuard);
if (!eclipseState_) {
#if HAVE_MPI
eclipseState_.reset(new Opm::ParallelEclipseState(*deck_));
#else
eclipseState_.reset(new Opm::EclipseState(*deck_));
#endif
}
/*
For the time being initializing wells and groups from the
restart file is not possible, but work is underways and it is
included here as a switch.
*/
const bool init_from_restart_file = !EWOMS_GET_PARAM(PreTypeTag, bool, SchedRestart);
const auto& init_config = eclipseState_->getInitConfig();
if (init_config.restartRequested() && init_from_restart_file) {
int report_step = init_config.getRestartStep();
const auto& rst_filename = eclipseState_->getIOConfig().getRestartFileName( init_config.getRestartRootName(), report_step, false );
Opm::EclIO::ERst rst_file(rst_filename);
const auto& rst_state = Opm::RestartIO::RstState::load(rst_file, report_step);
if (!schedule_)
schedule_.reset(new Opm::Schedule(*deck_, *eclipseState_, parseContext, errorGuard, python, &rst_state) );
}
else {
if (!schedule_)
schedule_.reset(new Opm::Schedule(*deck_, *eclipseState_, parseContext, errorGuard, python));
}
setupMessageLimiter_(schedule_->getMessageLimits(), "STDOUT_LOGGER");
if (!summaryConfig_)
summaryConfig_.reset( new Opm::SummaryConfig(*deck_, *schedule_, eclipseState_->getTableManager(), parseContext, errorGuard));
#if HAVE_MPI
parseSuccess = 1;
#endif
}
catch(const std::exception& e)
{
failureMessage = e.what();
}
}
#if HAVE_MPI
else {
if (!summaryConfig_)
summaryConfig_.reset(new Opm::SummaryConfig);
if (!schedule_)
schedule_.reset(new Opm::Schedule(python));
if (!eclipseState_)
eclipseState_.reset(new Opm::ParallelEclipseState);
}
auto comm = Dune::MPIHelper::getCollectiveCommunication();
parseSuccess = comm.max(parseSuccess);
if (!parseSuccess)
{
if (errorGuard) {
errorGuard.dump();
errorGuard.clear();
}
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
Opm::eclStateBroadcast(*eclipseState_, *schedule_, *summaryConfig_);
#endif
Opm::checkConsistentArrayDimensions(*eclipseState_, *schedule_, parseContext, errorGuard);
if (errorGuard) {
errorGuard.dump();
errorGuard.clear();
throw std::runtime_error("Unrecoverable errors were encountered while loading input.");
}
}
readDeck(mpiRank, deckFilename, deck_, eclipseState_, schedule_,
summaryConfig_, nullptr, python, std::move(parseContext),
init_from_restart_file, outputCout_);
setupTime_ = externalSetupTimer.elapsed();
outputFiles_ = (outputMode != FileOutputMode::OUTPUT_NONE);
}
@ -569,122 +498,6 @@ namespace Opm
}
void ensureOutputDirExists_(const std::string& cmdline_output_dir)
{
if (!Opm::filesystem::is_directory(cmdline_output_dir)) {
try {
Opm::filesystem::create_directories(cmdline_output_dir);
}
catch (...) {
throw std::runtime_error("Creation of output directory '" + cmdline_output_dir + "' failed\n");
}
}
}
// Setup the OpmLog backends
FileOutputMode setupLogging_(int mpi_rank_, const std::string& deck_filename, const std::string& cmdline_output_dir, const std::string& cmdline_output, bool output_cout_, const std::string& stdout_log_id) {
if (!cmdline_output_dir.empty()) {
ensureOutputDirExists_(cmdline_output_dir);
}
// create logFile
using Opm::filesystem::path;
path fpath(deck_filename);
std::string baseName;
std::ostringstream debugFileStream;
std::ostringstream logFileStream;
// Strip extension "." or ".DATA"
std::string extension = boost::to_upper_copy(fpath.extension().string());
if (extension == ".DATA" || extension == ".") {
baseName = boost::to_upper_copy(fpath.stem().string());
} else {
baseName = boost::to_upper_copy(fpath.filename().string());
}
std::string output_dir = cmdline_output_dir;
if (output_dir.empty()) {
output_dir = fpath.has_parent_path()
? absolute(fpath.parent_path()).generic_string()
: Opm::filesystem::current_path().generic_string();
}
logFileStream << output_dir << "/" << baseName;
debugFileStream << output_dir << "/" << baseName;
if (mpi_rank_ != 0) {
// Added rank to log file for non-zero ranks.
// This prevents message loss.
debugFileStream << "." << mpi_rank_;
// If the following file appears then there is a bug.
logFileStream << "." << mpi_rank_;
}
logFileStream << ".PRT";
debugFileStream << ".DBG";
FileOutputMode output;
{
static std::map<std::string, FileOutputMode> stringToOutputMode =
{ {"none", FileOutputMode::OUTPUT_NONE },
{"false", FileOutputMode::OUTPUT_LOG_ONLY },
{"log", FileOutputMode::OUTPUT_LOG_ONLY },
{"all" , FileOutputMode::OUTPUT_ALL },
{"true" , FileOutputMode::OUTPUT_ALL }};
auto outputModeIt = stringToOutputMode.find(cmdline_output);
if (outputModeIt != stringToOutputMode.end()) {
output = outputModeIt->second;
}
else {
output = FileOutputMode::OUTPUT_ALL;
std::cerr << "Value " << cmdline_output <<
" is not a recognized output mode. Using \"all\" instead."
<< std::endl;
}
}
if (output > FileOutputMode::OUTPUT_NONE) {
std::shared_ptr<Opm::EclipsePRTLog> prtLog = std::make_shared<Opm::EclipsePRTLog>(logFileStream.str(), Opm::Log::NoDebugMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("ECLIPSEPRTLOG", prtLog);
prtLog->setMessageLimiter(std::make_shared<Opm::MessageLimiter>());
prtLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(false));
}
if (output >= FileOutputMode::OUTPUT_LOG_ONLY) {
std::string debugFile = debugFileStream.str();
std::shared_ptr<Opm::StreamLog> debugLog = std::make_shared<Opm::EclipsePRTLog>(debugFileStream.str(), Opm::Log::DefaultMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("DEBUGLOG", debugLog);
}
if (mpi_rank_ == 0) {
std::shared_ptr<Opm::StreamLog> streamLog = std::make_shared<Opm::StreamLog>(std::cout, Opm::Log::StdoutMessageTypes);
Opm::OpmLog::addBackend(stdout_log_id, streamLog);
streamLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(true));
}
return output;
}
void setupMessageLimiter_(const Opm::MessageLimits msgLimits, const std::string& stdout_log_id) {
std::shared_ptr<Opm::StreamLog> stream_log = Opm::OpmLog::getBackend<Opm::StreamLog>(stdout_log_id);
const std::map<int64_t, int> limits = {{Opm::Log::MessageType::Note,
msgLimits.getCommentPrintLimit(0)},
{Opm::Log::MessageType::Info,
msgLimits.getMessagePrintLimit(0)},
{Opm::Log::MessageType::Warning,
msgLimits.getWarningPrintLimit(0)},
{Opm::Log::MessageType::Error,
msgLimits.getErrorPrintLimit(0)},
{Opm::Log::MessageType::Problem,
msgLimits.getProblemPrintLimit(0)},
{Opm::Log::MessageType::Bug,
msgLimits.getBugPrintLimit(0)}};
stream_log->setMessageLimiter(std::make_shared<Opm::MessageLimiter>(10, limits));
}
int argc_;
char** argv_;
bool outputCout_;
@ -693,10 +506,10 @@ namespace Opm
std::string deckFilename_;
std::string flowProgName_;
char *saveArgs_[2];
std::shared_ptr<Opm::Deck> deck_;
std::shared_ptr<Opm::EclipseState> eclipseState_;
std::shared_ptr<Opm::Schedule> schedule_;
std::shared_ptr<Opm::SummaryConfig> summaryConfig_;
std::unique_ptr<Opm::Deck> deck_;
std::unique_ptr<Opm::EclipseState> eclipseState_;
std::unique_ptr<Opm::Schedule> schedule_;
std::unique_ptr<Opm::SummaryConfig> summaryConfig_;
};
} // namespace Opm

View File

@ -0,0 +1,268 @@
/*
Copyright 2013, 2014, 2015 SINTEF ICT, Applied Mathematics.
Copyright 2014 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 IRIS AS
Copyright 2014 STATOIL ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#if HAVE_MPI
#include "mpi.h"
#endif
#include "readDeck.hpp"
#include <opm/common/utility/String.hpp>
#include <opm/io/eclipse/EclIOdata.hpp>
#include <opm/output/eclipse/RestartIO.hpp>
#include <opm/io/eclipse/rst/state.hpp>
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/simulators/flow/MissingFeatures.hpp>
#include <opm/simulators/utils/ParallelEclipseState.hpp>
#include <opm/simulators/utils/ParallelSerialization.hpp>
namespace Opm
{
void ensureOutputDirExists_(const std::string& cmdline_output_dir)
{
if (!Opm::filesystem::is_directory(cmdline_output_dir)) {
try {
Opm::filesystem::create_directories(cmdline_output_dir);
}
catch (...) {
throw std::runtime_error("Creation of output directory '" + cmdline_output_dir + "' failed\n");
}
}
}
// Setup the OpmLog backends
FileOutputMode setupLogging(int mpi_rank_, const std::string& deck_filename, const std::string& cmdline_output_dir, const std::string& cmdline_output, bool output_cout_, const std::string& stdout_log_id) {
if (!cmdline_output_dir.empty()) {
ensureOutputDirExists_(cmdline_output_dir);
}
// create logFile
using Opm::filesystem::path;
path fpath(deck_filename);
std::string baseName;
std::ostringstream debugFileStream;
std::ostringstream logFileStream;
// Strip extension "." or ".DATA"
std::string extension = uppercase(fpath.extension().string());
if (extension == ".DATA" || extension == ".") {
baseName = uppercase(fpath.stem().string());
} else {
baseName = uppercase(fpath.filename().string());
}
std::string output_dir = cmdline_output_dir;
if (output_dir.empty()) {
output_dir = fpath.has_parent_path()
? absolute(fpath.parent_path()).generic_string()
: Opm::filesystem::current_path().generic_string();
}
logFileStream << output_dir << "/" << baseName;
debugFileStream << output_dir << "/" << baseName;
if (mpi_rank_ != 0) {
// Added rank to log file for non-zero ranks.
// This prevents message loss.
debugFileStream << "." << mpi_rank_;
// If the following file appears then there is a bug.
logFileStream << "." << mpi_rank_;
}
logFileStream << ".PRT";
debugFileStream << ".DBG";
FileOutputMode output;
{
static std::map<std::string, FileOutputMode> stringToOutputMode =
{ {"none", FileOutputMode::OUTPUT_NONE },
{"false", FileOutputMode::OUTPUT_LOG_ONLY },
{"log", FileOutputMode::OUTPUT_LOG_ONLY },
{"all" , FileOutputMode::OUTPUT_ALL },
{"true" , FileOutputMode::OUTPUT_ALL }};
auto outputModeIt = stringToOutputMode.find(cmdline_output);
if (outputModeIt != stringToOutputMode.end()) {
output = outputModeIt->second;
}
else {
output = FileOutputMode::OUTPUT_ALL;
std::cerr << "Value " << cmdline_output <<
" is not a recognized output mode. Using \"all\" instead."
<< std::endl;
}
}
if (output > FileOutputMode::OUTPUT_NONE) {
std::shared_ptr<Opm::EclipsePRTLog> prtLog = std::make_shared<Opm::EclipsePRTLog>(logFileStream.str(), Opm::Log::NoDebugMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("ECLIPSEPRTLOG", prtLog);
prtLog->setMessageLimiter(std::make_shared<Opm::MessageLimiter>());
prtLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(false));
}
if (output >= FileOutputMode::OUTPUT_LOG_ONLY) {
std::string debugFile = debugFileStream.str();
std::shared_ptr<Opm::StreamLog> debugLog = std::make_shared<Opm::EclipsePRTLog>(debugFileStream.str(), Opm::Log::DefaultMessageTypes, false, output_cout_);
Opm::OpmLog::addBackend("DEBUGLOG", debugLog);
}
if (mpi_rank_ == 0) {
std::shared_ptr<Opm::StreamLog> streamLog = std::make_shared<Opm::StreamLog>(std::cout, Opm::Log::StdoutMessageTypes);
Opm::OpmLog::addBackend(stdout_log_id, streamLog);
streamLog->setMessageFormatter(std::make_shared<Opm::SimpleMessageFormatter>(true));
}
return output;
}
void setupMessageLimiter(const Opm::MessageLimits msgLimits, const std::string& stdout_log_id) {
std::shared_ptr<Opm::StreamLog> stream_log = Opm::OpmLog::getBackend<Opm::StreamLog>(stdout_log_id);
const std::map<int64_t, int> limits = {{Opm::Log::MessageType::Note,
msgLimits.getCommentPrintLimit(0)},
{Opm::Log::MessageType::Info,
msgLimits.getMessagePrintLimit(0)},
{Opm::Log::MessageType::Warning,
msgLimits.getWarningPrintLimit(0)},
{Opm::Log::MessageType::Error,
msgLimits.getErrorPrintLimit(0)},
{Opm::Log::MessageType::Problem,
msgLimits.getProblemPrintLimit(0)},
{Opm::Log::MessageType::Bug,
msgLimits.getBugPrintLimit(0)}};
stream_log->setMessageLimiter(std::make_shared<Opm::MessageLimiter>(10, limits));
}
void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& deck, std::unique_ptr<Opm::EclipseState>& eclipseState,
std::unique_ptr<Opm::Schedule>& schedule, std::unique_ptr<Opm::SummaryConfig>& summaryConfig,
std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Opm::Python>& python, std::unique_ptr<ParseContext> parseContext,
bool initFromRestart, bool checkDeck)
{
if (!errorGuard)
{
errorGuard = std::make_unique<ErrorGuard>();
}
#if HAVE_MPI
int parseSuccess = 0;
#endif
std::string failureMessage;
if (rank==0) {
try
{
if ( (!deck || !schedule || !summaryConfig ) && !parseContext)
{
OPM_THROW(std::logic_error, "We need a parse context if deck, schedule, or summaryConfig are not initialized");
}
if (!deck)
{
Opm::Parser parser;
deck = std::make_unique<Opm::Deck>( parser.parseFile(deckFilename , *parseContext, *errorGuard));
Opm::MissingFeatures::checkKeywords(*deck, *parseContext, *errorGuard);
if ( checkDeck )
Opm::checkDeck(*deck, parser, *parseContext, *errorGuard);
}
if (!eclipseState) {
#if HAVE_MPI
eclipseState = std::make_unique<Opm::ParallelEclipseState>(*deck);
#else
eclipseState = std::make_unique<Opm::EclipseState>(*deck);
#endif
}
/*
For the time being initializing wells and groups from the
restart file is not possible, but work is underways and it is
included here as a switch.
*/
const auto& init_config = eclipseState->getInitConfig();
if (init_config.restartRequested() && initFromRestart) {
int report_step = init_config.getRestartStep();
const auto& rst_filename = eclipseState->getIOConfig().getRestartFileName( init_config.getRestartRootName(), report_step, false );
Opm::EclIO::ERst rst_file(rst_filename);
const auto& rst_state = Opm::RestartIO::RstState::load(rst_file, report_step);
if (!schedule)
schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python, &rst_state);
}
else {
if (!schedule)
schedule = std::make_unique<Opm::Schedule>(*deck, *eclipseState, *parseContext, *errorGuard, python);
}
if (Opm::OpmLog::hasBackend("STDOUT_LOGGER")) // loggers might not be set up!
{
setupMessageLimiter(schedule->getMessageLimits(), "STDOUT_LOGGER");
}
if (!summaryConfig)
summaryConfig = std::make_unique<Opm::SummaryConfig>(*deck, *schedule, eclipseState->getTableManager(), *parseContext, *errorGuard);
#if HAVE_MPI
parseSuccess = 1;
#endif
}
catch(const std::exception& e)
{
failureMessage = e.what();
}
}
#if HAVE_MPI
else {
if (!summaryConfig)
summaryConfig = std::make_unique<Opm::SummaryConfig>();
if (!schedule)
schedule = std::make_unique<Opm::Schedule>(python);
if (!eclipseState)
eclipseState = std::make_unique<Opm::ParallelEclipseState>();
}
auto comm = Dune::MPIHelper::getCollectiveCommunication();
parseSuccess = comm.max(parseSuccess);
if (!parseSuccess)
{
if (*errorGuard) {
errorGuard->dump();
errorGuard->clear();
}
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}
Opm::eclStateBroadcast(*eclipseState, *schedule, *summaryConfig);
#endif
Opm::checkConsistentArrayDimensions(*eclipseState, *schedule, *parseContext, *errorGuard);
if (*errorGuard) {
errorGuard->dump();
errorGuard->clear();
throw std::runtime_error("Unrecoverable errors were encountered while loading input.");
}
}
} // end namespace Opm

View File

@ -0,0 +1,65 @@
/*
Copyright 2013, 2014, 2015 SINTEF ICT, Applied Mathematics.
Copyright 2014 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 IRIS AS
Copyright 2014 STATOIL ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_READDECK_HEADER_INCLUDED
#define OPM_READDECK_HEADER_INCLUDED
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/MessageLimits.hpp>
#include <memory>
#include <string>
namespace Opm
{
enum class FileOutputMode {
//! \brief No output to files.
OUTPUT_NONE = 0,
//! \brief Output only to log files, no eclipse output.
OUTPUT_LOG_ONLY = 1,
//! \brief Output to all files.
OUTPUT_ALL = 3
};
// Setup the OpmLog backends
FileOutputMode setupLogging(int mpi_rank_, const std::string& deck_filename, const std::string& cmdline_output_dir, const std::string& cmdline_output, bool output_cout_, const std::string& stdout_log_id);
void setupMessageLimiter(const Opm::MessageLimits msgLimits, const std::string& stdout_log_id);
/// \brief Reads the deck and creates all necessary objects if needed
///
/// If pointers already contains objects then they are used otherwise they are created and can be used outside later.
void readDeck(int rank, std::string& deckFilename, std::unique_ptr<Opm::Deck>& deck, std::unique_ptr<Opm::EclipseState>& eclipseState,
std::unique_ptr<Opm::Schedule>& schedule, std::unique_ptr<Opm::SummaryConfig>& summaryConfig,
std::unique_ptr<ErrorGuard> errorGuard, std::shared_ptr<Opm::Python>& python, std::unique_ptr<ParseContext> parseContext,
bool initFromRestart, bool checkDeck);
} // end namespace Opm
#endif // OPM_READDECK_HEADER_INCLUDED

View File

@ -17,6 +17,12 @@ DIMENS
REGDIMS
3 /
--
-- WELL WELL GRUPS GRUPS
-- MXWELS MXCONS MXGRPS MXGRPW
WELLDIMS
4 4 3 3 /
OIL
GAS
WATER