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:
Andreas Lauser 2017-10-10 13:14:29 +02:00
parent ef2e60e454
commit d51934ce37
3 changed files with 73 additions and 22 deletions

View File

@ -35,6 +35,10 @@
namespace Ewoms { namespace Ewoms {
namespace Properties { namespace Properties {
NEW_TYPE_TAG(EclProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem)); 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) int main(int argc, char **argv)

View File

@ -39,6 +39,8 @@
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp> #include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp> #include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <dune/common/deprecated.hh>
#if HAVE_MPI #if HAVE_MPI
#include <mpi.h> #include <mpi.h>
#endif // HAVE_MPI #endif // HAVE_MPI
@ -46,11 +48,14 @@
#include <vector> #include <vector>
#include <unordered_set> #include <unordered_set>
#include <array> #include <array>
#include <type_traits>
namespace Ewoms { namespace Ewoms {
template <class TypeTag> template <class TypeTag>
class EclBaseGridManager; class EclBaseGridManager;
struct EmptySimulationParameters; //< \deprecated, please remove ASAP!
namespace Properties { namespace Properties {
NEW_TYPE_TAG(EclBaseGridManager); NEW_TYPE_TAG(EclBaseGridManager);
@ -58,9 +63,13 @@ NEW_TYPE_TAG(EclBaseGridManager);
NEW_PROP_TAG(Grid); NEW_PROP_TAG(Grid);
NEW_PROP_TAG(EquilGrid); NEW_PROP_TAG(EquilGrid);
NEW_PROP_TAG(Scalar); NEW_PROP_TAG(Scalar);
NEW_PROP_TAG(EclDeckFileName); NEW_PROP_TAG(EclDeckFileName);
NEW_PROP_TAG(SimulatorParameter); //< \deprecated, please remove ASAP!
SET_STRING_PROP(EclBaseGridManager, EclDeckFileName, "ECLDECK.DATA"); SET_STRING_PROP(EclBaseGridManager, EclDeckFileName, "ECLDECK.DATA");
} // namespace Properties } // namespace Properties
/*! /*!
@ -147,33 +156,37 @@ public:
caseName_ = rawCaseName; caseName_ = rawCaseName;
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper); std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
if (!externalDeck_) { if (!getDeckFromSimulatorParameter_()) {
if (myRank == 0) if (!externalDeck_) {
std::cout << "Reading the deck file '" << fileName << "'" << std::endl; if (myRank == 0)
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
Opm::Parser parser; Opm::Parser parser;
typedef std::pair<std::string, Opm::InputError::Action> ParseModePair; typedef std::pair<std::string, Opm::InputError::Action> ParseModePair;
typedef std::vector<ParseModePair> ParseModePairs; typedef std::vector<ParseModePair> ParseModePairs;
ParseModePairs tmp; ParseModePairs tmp;
tmp.emplace_back(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE); 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::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_WELL, Opm::InputError::WARN);
tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN); tmp.emplace_back(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
Opm::ParseContext parseContext(tmp); Opm::ParseContext parseContext(tmp);
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext))); internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext)));
internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext)); internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext));
deck_ = &(*internalDeck_); deck_ = &(*internalDeck_);
eclState_ = &(*internalEclState_); eclState_ = &(*internalEclState_);
} }
else { // check if the deprecated SimulatorParameter mechanism is used to pass external
assert(externalDeck_); // parameters.
assert(externalEclState_); else {
assert(externalDeck_);
assert(externalEclState_);
deck_ = externalDeck_; deck_ = externalDeck_;
eclState_ = externalEclState_; eclState_ = externalEclState_;
}
} }
asImp_().createGrids_(); asImp_().createGrids_();
@ -288,6 +301,36 @@ private:
const Implementation& asImp_() const const Implementation& asImp_() const
{ return *static_cast<const Implementation*>(this); } { 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_; std::string caseName_;
static Opm::Deck* externalDeck_; static Opm::Deck* externalDeck_;

View File

@ -240,6 +240,10 @@ SET_BOOL_PROP(EclBaseProblem, EnableDebuggingChecks, true);
// ebos handles the SWATINIT keyword by default // ebos handles the SWATINIT keyword by default
SET_BOOL_PROP(EclBaseProblem, EnableSwatinit, true); 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 } // namespace Properties
/*! /*!