From 8846d4b7b8bb8ffa34cfd83e58db66cbe032fef1 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 3 Mar 2015 15:40:55 +0100 Subject: [PATCH] EclipseState: infer default region from GRIDOPTS --- .../eclipse/EclipseState/EclipseState.cpp | 53 +++++++++++++++++ .../eclipse/EclipseState/EclipseState.hpp | 3 + .../EclipseState/tests/EclipseStateTests.cpp | 59 +++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index d1ff72b97..846a7c3aa 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -122,12 +122,14 @@ namespace Opm { EclipseState::EclipseState(DeckConstPtr deck, LoggerPtr logger) + : m_defaultRegion("FLUXNUM") { m_deckUnitSystem = deck->getActiveUnitSystem(); initPhases(deck, logger); initTables(deck, logger); initEclipseGrid(deck, logger); + initGridopts(deck); initSchedule(deck, logger); initTitle(deck, logger); initProperties(deck, logger); @@ -415,6 +417,53 @@ namespace Opm { } + void EclipseState::initGridopts(DeckConstPtr deck) { + if (deck->hasKeyword("GRIDOPTS")) { + /* + The EQUALREG, MULTREG, COPYREG, ... keywords are used to + manipulate vectors based on region values; for instance + the statement + + EQUALREG + PORO 0.25 3 / -- Region array not specified + PERMX 100 3 F / + / + + will set the PORO field to 0.25 for all cells in region + 3 and the PERMX value to 100 mD for the same cells. The + fourth optional argument to the EQUALREG keyword is used + to indicate which REGION array should be used for the + selection. + + If the REGION array is not indicated (as in the PORO + case) above, the default region to use in the xxxREG + keywords depends on the GRIDOPTS keyword: + + 1. If GRIDOPTS is present, and the NRMULT item is + greater than zero, the xxxREG keywords will default + to use the MULTNUM region. + + 2. If the GRIDOPTS keyword is not present - or the + NRMULT item equals zero, the xxxREG keywords will + default to use the FLUXNUM keyword. + + This quite weird behaviour comes from reading the + GRIDOPTS and MULTNUM documentation, and practical + experience with ECLIPSE simulations. Ufortunately the + documentation of the xxxREG keywords does not confirm + this. + */ + + auto gridOpts = deck->getKeyword("GRIDOPTS"); + auto record = gridOpts->getRecord(0); + auto nrmult_item = record->getItem("NRMULT"); + + if (nrmult_item->getInt(0) > 0) + m_defaultRegion = "MULTNUM"; + } + } + + void EclipseState::initPhases(DeckConstPtr deck, LoggerPtr logger) { if (deck->hasKeyword("OIL")) phases.insert(Phase::PhaseEnum::OIL); @@ -559,6 +608,10 @@ namespace Opm { return gridProperty; } + std::shared_ptr > EclipseState::getDefaultRegion() const { + return m_intGridProperties->getInitializedKeyword( m_defaultRegion ); + } + /* Due to the post processor which might be applied to the diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index 1bbdc2d0d..7ea7f4b39 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -82,6 +82,7 @@ namespace Opm { std::string getTitle() const; bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const; + std::shared_ptr > getDefaultRegion() const; std::shared_ptr > getIntGridProperty( const std::string& keyword ) const; std::shared_ptr > getDoubleGridProperty( const std::string& keyword ) const; bool hasIntGridProperty(const std::string& keyword) const; @@ -132,6 +133,7 @@ namespace Opm { void initSchedule(DeckConstPtr deck, LoggerPtr logger); void initSimulationConfig(DeckConstPtr deck); void initEclipseGrid(DeckConstPtr deck, LoggerPtr logger); + void initGridopts(DeckConstPtr deck); void initPhases(DeckConstPtr deck, LoggerPtr logger); void initTitle(DeckConstPtr deck, LoggerPtr logger); void initProperties(DeckConstPtr deck, LoggerPtr logger); @@ -261,6 +263,7 @@ namespace Opm { std::shared_ptr > m_doubleGridProperties; std::shared_ptr m_transMult; std::shared_ptr m_faults; + std::string m_defaultRegion; }; typedef std::shared_ptr EclipseStatePtr; diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index 29ceb9818..ef4e37d9e 100644 --- a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -349,3 +349,62 @@ BOOST_AUTO_TEST_CASE(FaceTransMults) { } } } + + +static DeckPtr createDeckNoGridOpts() { + const char *deckData = + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "FLUXNUM\n" + " 1000*1 /\n" + "MULTNUM\n" + " 1000*1 /\n"; + + ParserPtr parser(new Parser()); + return parser->parseString(deckData) ; +} + + +static DeckPtr createDeckWithGridOpts() { + const char *deckData = + "RUNSPEC\n" + "GRIDOPTS\n" + " 'YES' 10 /" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "FLUXNUM\n" + " 1000*1 /\n" + "MULTNUM\n" + " 1000*1 /\n"; + + ParserPtr parser(new Parser()); + return parser->parseString(deckData) ; +} + + +BOOST_AUTO_TEST_CASE(NoGridOptsDefaultRegion) { + DeckPtr deck = createDeckNoGridOpts(); + EclipseState state(deck); + auto multnum = state.getIntGridProperty("MULTNUM"); + auto fluxnum = state.getIntGridProperty("FLUXNUM"); + auto def_property = state.getDefaultRegion(); + + BOOST_CHECK_EQUAL( fluxnum , def_property ); +} + + +BOOST_AUTO_TEST_CASE(WithGridOptsDefaultRegion) { + DeckPtr deck = createDeckWithGridOpts(); + EclipseState state(deck); + auto multnum = state.getIntGridProperty("MULTNUM"); + auto fluxnum = state.getIntGridProperty("FLUXNUM"); + auto def_property = state.getDefaultRegion(); + + BOOST_CHECK_EQUAL( multnum , def_property ); +} +