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 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)

View File

@ -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,6 +156,7 @@ public:
caseName_ = rawCaseName;
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
if (!getDeckFromSimulatorParameter_()) {
if (!externalDeck_) {
if (myRank == 0)
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
@ -168,6 +178,8 @@ public:
deck_ = &(*internalDeck_);
eclState_ = &(*internalEclState_);
}
// check if the deprecated SimulatorParameter mechanism is used to pass external
// parameters.
else {
assert(externalDeck_);
assert(externalEclState_);
@ -175,6 +187,7 @@ public:
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_;

View File

@ -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
/*!