ebos: simplify passing of pre-parsed ECL decks

This gets rid of some special-purpose code in generic places (i.e. the
`SimulatorParameter` class) and no special hacks to the property and
parameter system are required anymore.
This commit is contained in:
Andreas Lauser 2017-10-05 16:15:17 +02:00
parent 415fdfd113
commit ef2e60e454
2 changed files with 51 additions and 21 deletions

View File

@ -93,6 +93,22 @@ public:
"The name of the file which contains the ECL deck to be simulated");
}
/*!
* \brief Set the Opm::EclipseState and the Opm::Deck object which ought to be used
* when the grid manager is instantiated.
*
* This is basically an optimization: In cases where the ECL input deck must be
* examined to decide which simulator ought to be used, this avoids having to parse
* the input twice. When this method is used, the caller is responsible for lifetime
* management of these two objects, i.e., they are not allowed to be deleted as long
* as the grid manager object is alive.
*/
static void setExternalDeck(Opm::Deck* deck, Opm::EclipseState* eclState)
{
externalDeck_ = deck;
externalEclState_ = eclState;
}
/*!
* \brief Create the grid for problem data files which use the ECL file format.
*
@ -131,29 +147,33 @@ public:
caseName_ = rawCaseName;
std::transform(caseName_.begin(), caseName_.end(), caseName_.begin(), ::toupper);
if (myRank == 0)
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
if (!externalDeck_) {
if (myRank == 0)
std::cout << "Reading the deck file '" << fileName << "'" << std::endl;
if( ! simulator.simulatorParameter().first )
{
Opm::Parser parser;
typedef std::pair<std::string, Opm::InputError::Action> ParseModePair;
typedef std::vector<ParseModePair> ParseModePairs;
ParseModePairs tmp;
tmp.push_back(ParseModePair(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE));
tmp.push_back(ParseModePair(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN));
tmp.push_back(ParseModePair(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN));
tmp.push_back(ParseModePair(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN));
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);
deck_.reset( new Opm::Deck(parser.parseFile(fileName , parseContext)) );
eclState_.reset(new Opm::EclipseState(deck(), parseContext));
internalDeck_.reset(new Opm::Deck(parser.parseFile(fileName , parseContext)));
internalEclState_.reset(new Opm::EclipseState(*internalDeck_, parseContext));
deck_ = &(*internalDeck_);
eclState_ = &(*internalEclState_);
}
else
{
deck_ = simulator.simulatorParameter().first;
assert( simulator.simulatorParameter().second );
eclState_ = simulator.simulatorParameter().second;
else {
assert(externalDeck_);
assert(externalEclState_);
deck_ = externalDeck_;
eclState_ = externalEclState_;
}
asImp_().createGrids_();
@ -269,10 +289,24 @@ private:
{ return *static_cast<const Implementation*>(this); }
std::string caseName_;
std::shared_ptr<Opm::Deck> deck_;
std::shared_ptr<Opm::EclipseState> eclState_;
static Opm::Deck* externalDeck_;
static Opm::EclipseState* externalEclState_;
std::unique_ptr<Opm::Deck> internalDeck_;
std::unique_ptr<Opm::EclipseState> internalEclState_;
// these two attributes point either to the internal or to the external version of the
// Deck and EclipsState objects.
Opm::Deck* deck_;
Opm::EclipseState* eclState_;
};
template <class TypeTag>
Opm::Deck* EclBaseGridManager<TypeTag>::externalDeck_ = nullptr;
template <class TypeTag>
Opm::EclipseState* EclBaseGridManager<TypeTag>::externalEclState_;
} // namespace Ewoms
#endif

View File

@ -240,10 +240,6 @@ SET_BOOL_PROP(EclBaseProblem, EnableDebuggingChecks, true);
// ebos handles the SWATINIT keyword by default
SET_BOOL_PROP(EclBaseProblem, EnableSwatinit, true);
//! Set the ParameterMetaData property
SET_TYPE_PROP(EclBaseProblem, SimulatorParameter, std::pair< std::shared_ptr<Opm::Deck>, std::shared_ptr<Opm::EclipseState> > );
} // namespace Properties
/*!