mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
ebos: don't break the downstream build because of the SimulatorParameter mess
this now works with the unmodified master version of flow from opm-simulators. we take the liberty to emit a deprecation warning, though. this complicates things quite a bit.
This commit is contained in:
parent
ef2e60e454
commit
d51934ce37
@ -35,6 +35,10 @@
|
||||
namespace Ewoms {
|
||||
namespace Properties {
|
||||
NEW_TYPE_TAG(EclProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem));
|
||||
|
||||
//! Set the SimulatorParameter to be empty to avoid the deprecation warnings.
|
||||
//! THE SimulatorParameter MECHANISM IS A DEPRECATED HACK, PLEASE REMOVE IT ASAP!
|
||||
SET_TYPE_PROP(EclProblem, SimulatorParameter, Ewoms::EmptySimulationParameters);
|
||||
}}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
|
||||
#include <dune/common/deprecated.hh>
|
||||
|
||||
#if HAVE_MPI
|
||||
#include <mpi.h>
|
||||
#endif // HAVE_MPI
|
||||
@ -46,11 +48,14 @@
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include <array>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Ewoms {
|
||||
template <class TypeTag>
|
||||
class EclBaseGridManager;
|
||||
|
||||
struct EmptySimulationParameters; //< \deprecated, please remove ASAP!
|
||||
|
||||
namespace Properties {
|
||||
NEW_TYPE_TAG(EclBaseGridManager);
|
||||
|
||||
@ -58,9 +63,13 @@ NEW_TYPE_TAG(EclBaseGridManager);
|
||||
NEW_PROP_TAG(Grid);
|
||||
NEW_PROP_TAG(EquilGrid);
|
||||
NEW_PROP_TAG(Scalar);
|
||||
|
||||
NEW_PROP_TAG(EclDeckFileName);
|
||||
|
||||
NEW_PROP_TAG(SimulatorParameter); //< \deprecated, please remove ASAP!
|
||||
|
||||
SET_STRING_PROP(EclBaseGridManager, EclDeckFileName, "ECLDECK.DATA");
|
||||
|
||||
} // namespace Properties
|
||||
|
||||
/*!
|
||||
@ -147,33 +156,37 @@ public:
|
||||
caseName_ = rawCaseName;
|
||||
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
|
||||
|
||||
if (!externalDeck_) {
|
||||
if (myRank == 0)
|
||||
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
|
||||
if (!getDeckFromSimulatorParameter_()) {
|
||||
if (!externalDeck_) {
|
||||
if (myRank == 0)
|
||||
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
|
||||
|
||||
Opm::Parser parser;
|
||||
typedef std::pair<std::string, Opm::InputError::Action> ParseModePair;
|
||||
typedef std::vector<ParseModePair> ParseModePairs;
|
||||
Opm::Parser parser;
|
||||
typedef std::pair<std::string, Opm::InputError::Action> ParseModePair;
|
||||
typedef std::vector<ParseModePair> ParseModePairs;
|
||||
|
||||
ParseModePairs tmp;
|
||||
tmp.emplace_back(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
|
||||
tmp.emplace_back(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
|
||||
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
|
||||
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
|
||||
Opm::ParseContext parseContext(tmp);
|
||||
ParseModePairs tmp;
|
||||
tmp.emplace_back(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
|
||||
tmp.emplace_back(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
|
||||
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
|
||||
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
|
||||
Opm::ParseContext parseContext(tmp);
|
||||
|
||||
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext)));
|
||||
internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext));
|
||||
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext)));
|
||||
internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext));
|
||||
|
||||
deck_ = &(*internalDeck_);
|
||||
eclState_ = &(*internalEclState_);
|
||||
}
|
||||
else {
|
||||
assert(externalDeck_);
|
||||
assert(externalEclState_);
|
||||
deck_ = &(*internalDeck_);
|
||||
eclState_ = &(*internalEclState_);
|
||||
}
|
||||
// check if the deprecated SimulatorParameter mechanism is used to pass external
|
||||
// parameters.
|
||||
else {
|
||||
assert(externalDeck_);
|
||||
assert(externalEclState_);
|
||||
|
||||
deck_ = externalDeck_;
|
||||
eclState_ = externalEclState_;
|
||||
deck_ = externalDeck_;
|
||||
eclState_ = externalEclState_;
|
||||
}
|
||||
}
|
||||
|
||||
asImp_().createGrids_();
|
||||
@ -288,6 +301,36 @@ private:
|
||||
const Implementation& asImp_() const
|
||||
{ return *static_cast<const Implementation*>(this); }
|
||||
|
||||
// set the deck via the deprecated SimulatorParameter mechanism. The template-foo
|
||||
// ensures that if the simulator parameters are non-empty, a deprecation warning is
|
||||
// produced.
|
||||
typedef typename GET_PROP_TYPE(TypeTag, SimulatorParameter) SimulatorParameter;
|
||||
template <class SimParam = SimulatorParameter>
|
||||
DUNE_DEPRECATED_MSG("Use static setExternalDeck() to pass external parameters to the instead of SimulatorParameter mechanism")
|
||||
typename std::enable_if<!std::is_same<SimParam, Ewoms::EmptySimulationParameters>::value,
|
||||
bool>::type
|
||||
getDeckFromSimulatorParameter_()
|
||||
{
|
||||
const auto& simParam = this->simulator_.simulatorParameter();
|
||||
if (simParam.first) {
|
||||
externalDeck_ = &(*simParam.first);
|
||||
externalEclState_ = &(*simParam.second);
|
||||
|
||||
deck_ = externalDeck_;
|
||||
eclState_ = externalEclState_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class SimParam = SimulatorParameter>
|
||||
typename std::enable_if<std::is_same<SimParam, Ewoms::EmptySimulationParameters>::value,
|
||||
bool>::type
|
||||
getDeckFromSimulatorParameter_()
|
||||
{ return false; }
|
||||
|
||||
std::string caseName_;
|
||||
|
||||
static Opm::Deck* externalDeck_;
|
||||
|
@ -240,6 +240,10 @@ SET_BOOL_PROP(EclBaseProblem, EnableDebuggingChecks, true);
|
||||
|
||||
// ebos handles the SWATINIT keyword by default
|
||||
SET_BOOL_PROP(EclBaseProblem, EnableSwatinit, true);
|
||||
|
||||
//! Set the SimulatorParameter property. THIS IS A DEPRECATED HACK, PLEASE REMOVE ASAP!
|
||||
SET_TYPE_PROP(EclBaseProblem, SimulatorParameter, std::pair< std::shared_ptr<Opm::Deck>, std::shared_ptr<Opm::EclipseState> > );
|
||||
|
||||
} // namespace Properties
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user