From dbbbd2e8f7af87a38266d2419902afb853eca9a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Fri, 18 Mar 2016 13:55:48 +0100 Subject: [PATCH 01/13] Parser support for SUMMARY/Region keywords The Summary object understands and stores some (simple) Region type keywords. Does not support inter-region keywords, nor underscore or custom regions. --- .../eclipse/EclipseState/Summary/Summary.cpp | 23 +++++++++++++++++++ .../Summary/tests/SummaryTests.cpp | 22 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 2a3c905a1..473b4f0f4 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -103,6 +103,28 @@ namespace Opm { return fun::map( mkrecord, keyword ); } + static inline std::vector< ERT::smspec_node > keywordR( + const DeckKeyword& keyword, + const EclipseState& es ) { + + std::array< int, 3 > dims = {{ + int( es.getEclipseGrid()->getNX() ), + int( es.getEclipseGrid()->getNY() ), + int( es.getEclipseGrid()->getNZ() ) + }}; + + const auto mknode = [&dims,&keyword]( int region ) { + return ERT::smspec_node( keyword.name(), dims.data(), region ); + }; + + const auto& item = keyword.getDataRecord().getDataItem(); + const auto regions = item.size() > 0 && item.hasValue( 0 ) + ? item.getData< int >() + : es.getRegions(); + + return fun::map( mknode, regions ); + } + std::vector< ERT::smspec_node > handleKW( const DeckKeyword& keyword, const EclipseState& es ) { const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() ); @@ -111,6 +133,7 @@ namespace Opm { case ECL_SMSPEC_GROUP_VAR: return keywordWG( var_type, keyword, es ); case ECL_SMSPEC_FIELD_VAR: return keywordF( keyword, es ); case ECL_SMSPEC_BLOCK_VAR: return keywordB( keyword, es ); + case ECL_SMSPEC_REGION_VAR: return keywordR( keyword, es ); default: return {}; } diff --git a/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp b/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp index 7b8d7810b..f8f556142 100644 --- a/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp @@ -39,6 +39,9 @@ static DeckPtr createDeck( const std::string& summary ) { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "REGIONS\n" + "FIPNUM\n" + "200*1 300*2 500*3 /\n" "SCHEDULE\n" "WELSPECS\n" " \'W_1\' \'OP\' 30 37 3.33 \'OIL\' 7* / \n" @@ -122,3 +125,22 @@ BOOST_AUTO_TEST_CASE(blocks) { keywords.begin(), keywords.end(), names.begin(), names.end() ); } + +BOOST_AUTO_TEST_CASE(regions) { + const auto input = "ROIP\n" + "1 2 3 /\n" + "RWIP\n" + "/\n" + "RGIP\n" + "1 2 /\n"; + + const auto summary = createSummary( input ); + const auto keywords = { "RGIP", "RGIP", + "ROIP", "ROIP", "ROIP", + "RWIP", "RWIP", "RWIP" }; + const auto names = sorted_keywords( summary ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + keywords.begin(), keywords.end(), + names.begin(), names.end() ); +} From e4d51c5d35d47eed35042d3b64b59b9c88307f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 12:02:42 +0200 Subject: [PATCH 02/13] Summary: Calculate dims from grid in function To reduce duplication, calculating a dimensions array from EclipseGrid is its own function instead for a repeated body across multiple (similar) functions. --- .../eclipse/EclipseState/Summary/Summary.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 473b4f0f4..3ded184f4 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -79,15 +79,19 @@ namespace Opm { return res; } + static inline std::array< int, 3 > dimensions( const EclipseGrid& grid ) { + return { + int( grid.getNX() ), + int( grid.getNY() ), + int( grid.getNZ() ) + }; + } + static inline std::vector< ERT::smspec_node > keywordB( const DeckKeyword& keyword, const EclipseState& es ) { - std::array< int, 3 > dims = {{ - int( es.getEclipseGrid()->getNX() ), - int( es.getEclipseGrid()->getNY() ), - int( es.getEclipseGrid()->getNZ() ) - }}; + auto dims = dimensions( *es.getEclipseGrid() ); const auto mkrecord = [&dims,&keyword]( const DeckRecord& record ) { @@ -107,11 +111,7 @@ namespace Opm { const DeckKeyword& keyword, const EclipseState& es ) { - std::array< int, 3 > dims = {{ - int( es.getEclipseGrid()->getNX() ), - int( es.getEclipseGrid()->getNY() ), - int( es.getEclipseGrid()->getNZ() ) - }}; + auto dims = dimensions( *es.getEclipseGrid() ); const auto mknode = [&dims,&keyword]( int region ) { return ERT::smspec_node( keyword.name(), dims.data(), region ); From 0c3a2093f220884b4efa19b7eb041116cec655b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 12:11:54 +0200 Subject: [PATCH 03/13] Summary: Calculate ijk from record in function To reduce duplication, calculating ijk positions with offset from records is handled by a function instead of inline. --- .../eclipse/EclipseState/Summary/Summary.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 3ded184f4..4cb610895 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -87,6 +87,16 @@ namespace Opm { }; } + static inline std::array< int, 3 > getijk( const DeckRecord& record, + int init = 0 ) + { + return { + record.getItem( init + 0 ).get< int >( 0 ) - 1, + record.getItem( init + 1 ).get< int >( 0 ) - 1, + record.getItem( init + 2 ).get< int >( 0 ) - 1 + }; + } + static inline std::vector< ERT::smspec_node > keywordB( const DeckKeyword& keyword, const EclipseState& es ) { @@ -94,13 +104,7 @@ namespace Opm { auto dims = dimensions( *es.getEclipseGrid() ); const auto mkrecord = [&dims,&keyword]( const DeckRecord& record ) { - - std::array< int , 3 > ijk = {{ - record.getItem( 0 ).get< int >( 0 ) - 1, - record.getItem( 1 ).get< int >( 0 ) - 1, - record.getItem( 2 ).get< int >( 0 ) - 1 - }}; - + auto ijk = getijk( record ); return ERT::smspec_node( keyword.name(), dims.data(), ijk.data() ); }; From 2ed88df0db8092fa85acf4902ccf92245dd67b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 14:13:22 +0200 Subject: [PATCH 04/13] CompletionSet iterator support --- opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp b/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp index 98576691e..da4dec348 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp @@ -31,12 +31,18 @@ namespace Opm { class CompletionSet { public: + using const_iterator = std::vector< std::shared_ptr< const Completion > >::const_iterator; + CompletionSet(); void add(std::shared_ptr< const Completion > completion); size_t size() const; CompletionSet * shallowCopy() const; std::shared_ptr< const Completion > get(size_t index) const; std::shared_ptr< const Completion > getFromIJK(const int i, const int j, const int k) const; + + const_iterator begin() const { return this->m_completions.begin(); } + const_iterator end() const { return this->m_completions.end(); } + bool allCompletionsShut() const; /// Order completions irrespective of input order. /// The algorithm used is the following: From 2e58d42ad0772f9dfc52b07c9ee7f2275687e93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 14:13:54 +0200 Subject: [PATCH 05/13] Schedule::getWell const support --- opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp | 4 ++++ opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index cdfb219bd..3dc807999 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1497,6 +1497,10 @@ namespace Opm { return m_wells.get( wellName ); } + const Well& Schedule::getWell(const std::string& wellName) const { + return *m_wells.get( wellName ); + } + /* Observe that this method only returns wells which have state == diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index ecde99e4a..816bdacf0 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -63,6 +63,7 @@ namespace Opm size_t getMaxNumCompletionsForWells(size_t timestep) const; bool hasWell(const std::string& wellName) const; std::shared_ptr< Well > getWell(const std::string& wellName); + const Well& getWell(const std::string& wellName) const; std::vector> getOpenWells(size_t timeStep); std::vector> getWells() const; std::vector> getWells(size_t timeStep) const; From 6ce846ca0b631708aca072a8ca1f249fe946cddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 14:14:13 +0200 Subject: [PATCH 06/13] TimeMap::last() support Query the last time step of the map. --- opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp | 4 ++++ opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp b/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp index 9d19bd970..e0901f73e 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp +++ b/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp @@ -111,6 +111,10 @@ namespace Opm { return m_timeList.size(); } + size_t TimeMap::last() const { + return this->numTimesteps(); + } + const std::map& TimeMap::eclipseMonthNames() { static std::map monthNames; diff --git a/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp b/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp index 52bb41b40..04cb769b7 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp @@ -42,6 +42,7 @@ namespace Opm { void initFirstTimestepsMonths(); void initFirstTimestepsYears(); size_t size() const; + size_t last() const; size_t numTimesteps() const; double getTotalTime() const; const boost::posix_time::ptime& operator[] (size_t index) const; From 44b19a04ea6fcc424e3acd6ae19ba097ed146d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Tue, 29 Mar 2016 14:15:03 +0200 Subject: [PATCH 07/13] Internalisation of SUMMARY C keywords Implement support for creating and instantiation smspec_nodes for the C-family of keywords of the SUMMARY section. Covers all defaulting mechanisms. Due to poor map/concat/filter support, this was written in a more traditional foreach-if-then-append style. --- .../eclipse/EclipseState/Summary/Summary.cpp | 64 ++++++++++++++++++- .../Summary/tests/SummaryTests.cpp | 38 +++++++++-- 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 4cb610895..1094dee36 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -25,15 +25,18 @@ #include #include #include +#include +#include #include #include +#include #include #include #include #include -#include +#include #include namespace Opm { @@ -97,6 +100,10 @@ namespace Opm { }; } + static inline std::array< int, 3 > getijk( const Completion& completion ) { + return { completion.getI(), completion.getJ(), completion.getK() }; + } + static inline std::vector< ERT::smspec_node > keywordB( const DeckKeyword& keyword, const EclipseState& es ) { @@ -129,6 +136,60 @@ namespace Opm { return fun::map( mknode, regions ); } + static inline std::vector< ERT::smspec_node > keywordC( + const DeckKeyword& keyword, + const EclipseState& es ) { + + std::vector< ERT::smspec_node > nodes; + const auto& keywordstring = keyword.name(); + const auto& schedule = es.getSchedule(); + const auto last_timestep = schedule->getTimeMap()->last(); + auto dims = dimensions( *es.getEclipseGrid() ); + + for( const auto& record : keyword ) { + + const auto& wellname = record.getItem( 0 ).get< std::string >( 0 ); + + if( wellname == "*" ) { + for( const auto& well : schedule->getWells() ) { + + const auto& name = wellName( well ); + + for( const auto& completion : *well->getCompletions( last_timestep ) ) { + auto cijk = getijk( *completion ); + + /* well defaulted, block coordinates defaulted */ + if( record.size() != 4 ) { + nodes.emplace_back( keywordstring, name, dims.data(), cijk.data() ); + } + /* well defaulted, block coordinates specified */ + else { + auto recijk = getijk( record, 1 ); + if( std::equal( recijk.begin(), recijk.end(), cijk.begin() ) ) + nodes.emplace_back( keywordstring, name, dims.data(), cijk.data() ); + } + } + } + + } else { + /* all specified */ + if( !record.getItem( 1 ).defaultApplied( 0 ) ) { + auto ijk = getijk( record, 1 ); + nodes.emplace_back( keywordstring, wellname, dims.data(), ijk.data() ); + } + else { + /* well specified, block coordinates defaulted */ + for( const auto& completion : *schedule->getWell( wellname ).getCompletions( last_timestep ) ) { + auto ijk = getijk( *completion ); + nodes.emplace_back( keywordstring, wellname, dims.data(), ijk.data() ); + } + } + } + } + + return nodes; + } + std::vector< ERT::smspec_node > handleKW( const DeckKeyword& keyword, const EclipseState& es ) { const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() ); @@ -138,6 +199,7 @@ namespace Opm { case ECL_SMSPEC_FIELD_VAR: return keywordF( keyword, es ); case ECL_SMSPEC_BLOCK_VAR: return keywordB( keyword, es ); case ECL_SMSPEC_REGION_VAR: return keywordR( keyword, es ); + case ECL_SMSPEC_COMPLETION_VAR: return keywordC( keyword, es ); default: return {}; } diff --git a/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp b/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp index f8f556142..d7ca20226 100644 --- a/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/tests/SummaryTests.cpp @@ -39,14 +39,24 @@ static DeckPtr createDeck( const std::string& summary ) { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DXV \n 10*400 /\n" + "DYV \n 10*400 /\n" + "DZV \n 10*400 /\n" + "TOPS \n 100*2202 / \n" "REGIONS\n" "FIPNUM\n" "200*1 300*2 500*3 /\n" "SCHEDULE\n" "WELSPECS\n" - " \'W_1\' \'OP\' 30 37 3.33 \'OIL\' 7* / \n" - " \'WX2\' \'OP\' 30 37 3.33 \'OIL\' 7* / \n" - " \'W_3\' \'OP\' 20 51 3.92 \'OIL\' 7* / \n" + " \'W_1\' \'OP\' 1 1 3.33 \'OIL\' 7* / \n" + " \'WX2\' \'OP\' 2 2 3.33 \'OIL\' 7* / \n" + " \'W_3\' \'OP\' 2 5 3.92 \'OIL\' 7* / \n" + " 'PRODUCER' 'G' 5 5 2000 'GAS' /\n" + "/\n" + "COMPDAT\n" + "'PRODUCER' 5 5 1 1 'OPEN' 1* -1 0.5 / \n" + "'W_1' 3 7 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / \n" + "'W_1' 3 7 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / \n" "/\n" "SUMMARY\n" + summary; @@ -82,7 +92,7 @@ BOOST_AUTO_TEST_CASE(wells_all) { const auto input = "WWCT\n/\n"; const auto summary = createSummary( input ); - const auto wells = { "WX2", "W_1", "W_3" }; + const auto wells = { "PRODUCER", "WX2", "W_1", "W_3" }; const auto names = sorted_names( summary ); BOOST_CHECK_EQUAL_COLLECTIONS( @@ -144,3 +154,23 @@ BOOST_AUTO_TEST_CASE(regions) { keywords.begin(), keywords.end(), names.begin(), names.end() ); } + +BOOST_AUTO_TEST_CASE(completions) { + const auto input = "CWIR\n" + "'PRODUCER' /\n" + "'WX2' 1 1 1 /\n" + "'WX2' 2 2 2 /\n" + "/\n" + "CWIT\n" + "'W_1' /\n" + "/\n"; + + const auto summary = createSummary( input ); + const auto keywords = { "CWIR", "CWIR", "CWIR", + "CWIT", "CWIT", "CWIT" }; + const auto names = sorted_keywords( summary ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + keywords.begin(), keywords.end(), + names.begin(), names.end() ); +} From a705b0750bc06f87df437d46ff9a33dc5dba5b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Thu, 17 Mar 2016 10:01:38 +0100 Subject: [PATCH 08/13] Query all IDs of (FIP) regions in State Enable support for querying what fluid-in-point regions are defined in the deck. For now the only interesting regions are the ones specified by the FIPNUM keyword in the REGIONS section. The implementation is somewhat inefficient (n log n over the number of cells in the grid), but since this is likely to only be called when default-expanding SUMMARY section keywords this isn't too bad, since the implementation is so dead simple. --- .../eclipse/EclipseState/EclipseState.cpp | 14 ++++++++++ .../eclipse/EclipseState/EclipseState.hpp | 11 +++++--- .../EclipseState/tests/EclipseStateTests.cpp | 28 +++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index e1b996fb9..6f876260b 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -17,6 +17,8 @@ along with OPM. If not, see . */ +#include + #include #include @@ -243,6 +245,18 @@ namespace Opm { m_transMult->setMultregtScanner( scanner ); } + std::vector< int > EclipseState::getRegions( const std::string& kw ) const { + if( !this->get3DProperties().hasDeckIntGridProperty( kw ) ) return {}; + + const auto& property = this->get3DProperties().getIntGridProperty( kw ); + + std::set< int > regions( property.getData().begin(), + property.getData().end() ); + + return { regions.begin(), regions.end() }; + } + + void EclipseState::complainAboutAmbiguousKeyword(DeckConstPtr deck, const std::string& keywordName) const { OpmLog::addMessage(Log::MessageType::Error, "The " + keywordName + " keyword must be unique in the deck. Ignoring all!"); auto keywords = deck->getKeywordList(keywordName); diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index 5f844c375..7f1697c6e 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -20,9 +20,10 @@ #ifndef OPM_ECLIPSE_STATE_HPP #define OPM_ECLIPSE_STATE_HPP -#include #include #include +#include +#include #include #include @@ -88,9 +89,11 @@ namespace Opm { const TableManager& getTableManager() const; - // the unit system used by the deck. note that it is rarely needed to - // convert units because internally to opm-parser everything is - // represented by SI units... + std::vector< int > getRegions( const std::string& kw ) const; + + // the unit system used by the deck. note that it is rarely needed to convert + // units because internally to opm-parser everything is represented by SI + // units... const UnitSystem& getDeckUnitSystem() const; void applyModifierDeck( std::shared_ptr deck); diff --git a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index 23624d30b..255a53979 100644 --- a/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -580,3 +580,31 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTSOL) { BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(0)); } } + +BOOST_AUTO_TEST_CASE(getRegions) { + const char* input = + "START -- 0 \n" + "10 MAI 2007 / \n" + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 2 2 1 /\n" + "GRID\n" + "DXV \n 2*400 /\n" + "DYV \n 2*400 /\n" + "DZV \n 1*400 /\n" + "REGIONS\n" + "FIPNUM\n" + "1 1 2 3 /\n"; + + const auto deck = Parser().parseString(input, ParseContext()); + EclipseState es( deck, ParseContext() ); + + std::vector< int > ref = { 1, 2, 3 }; + const auto regions = es.getRegions( "FIPNUM" ); + + BOOST_CHECK_EQUAL_COLLECTIONS( ref.begin(), ref.end(), + regions.begin(), regions.end() ); + + BOOST_CHECK( es.getRegions( "EQLNUM" ).empty() ); +} From 302e656ea47aff520bfdb661de1fd568f9516aa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Thu, 14 Apr 2016 09:42:36 +0200 Subject: [PATCH 09/13] fixup! Internalisation of SUMMARY C keywords --- opm/parser/eclipse/EclipseState/Summary/Summary.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 1094dee36..d7ceb1c26 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -148,9 +148,7 @@ namespace Opm { for( const auto& record : keyword ) { - const auto& wellname = record.getItem( 0 ).get< std::string >( 0 ); - - if( wellname == "*" ) { + if( record.getItem( 0 ).defaultApplied( 0 ) ) { for( const auto& well : schedule->getWells() ) { const auto& name = wellName( well ); @@ -159,7 +157,7 @@ namespace Opm { auto cijk = getijk( *completion ); /* well defaulted, block coordinates defaulted */ - if( record.size() != 4 ) { + if( record.getItem( 1 ).defaultApplied( 0 ) ) { nodes.emplace_back( keywordstring, name, dims.data(), cijk.data() ); } /* well defaulted, block coordinates specified */ @@ -172,16 +170,17 @@ namespace Opm { } } else { + const auto& name = record.getItem( 0 ).get< std::string >( 0 ); /* all specified */ if( !record.getItem( 1 ).defaultApplied( 0 ) ) { auto ijk = getijk( record, 1 ); - nodes.emplace_back( keywordstring, wellname, dims.data(), ijk.data() ); + nodes.emplace_back( keywordstring, name, dims.data(), ijk.data() ); } else { /* well specified, block coordinates defaulted */ - for( const auto& completion : *schedule->getWell( wellname ).getCompletions( last_timestep ) ) { + for( const auto& completion : *schedule->getWell( name ).getCompletions( last_timestep ) ) { auto ijk = getijk( *completion ); - nodes.emplace_back( keywordstring, wellname, dims.data(), ijk.data() ); + nodes.emplace_back( keywordstring, name, dims.data(), ijk.data() ); } } } From 2b6d87124238cbfd81c7e3755616337adfb50b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Thu, 14 Apr 2016 09:43:43 +0200 Subject: [PATCH 10/13] fixup! Summary: Calculate ijk from record in function --- opm/parser/eclipse/EclipseState/Summary/Summary.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index d7ceb1c26..5843ba932 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -91,12 +91,12 @@ namespace Opm { } static inline std::array< int, 3 > getijk( const DeckRecord& record, - int init = 0 ) + int offset = 0 ) { return { - record.getItem( init + 0 ).get< int >( 0 ) - 1, - record.getItem( init + 1 ).get< int >( 0 ) - 1, - record.getItem( init + 2 ).get< int >( 0 ) - 1 + record.getItem( offset + 0 ).get< int >( 0 ) - 1, + record.getItem( offset + 1 ).get< int >( 0 ) - 1, + record.getItem( offset + 2 ).get< int >( 0 ) - 1 }; } From fba6069b7d09e5d54eca0ad2eddcb7e62add0a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Date: Thu, 14 Apr 2016 09:44:08 +0200 Subject: [PATCH 11/13] fixup! Parser support for SUMMARY/Region keywords --- opm/parser/eclipse/EclipseState/Summary/Summary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 5843ba932..2f3c088a5 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -131,7 +131,7 @@ namespace Opm { const auto& item = keyword.getDataRecord().getDataItem(); const auto regions = item.size() > 0 && item.hasValue( 0 ) ? item.getData< int >() - : es.getRegions(); + : es.getRegions( "FIPNUM" ); return fun::map( mknode, regions ); } From 209d30f0d02386f3fd54796e1b1e31b224b574fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 14 Apr 2016 14:51:42 +0200 Subject: [PATCH 12/13] Silence missing-braces warning. Can switch back when we move to C++14 uniformly. --- opm/parser/eclipse/EclipseState/Summary/Summary.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp index 2f3c088a5..b27d277a3 100644 --- a/opm/parser/eclipse/EclipseState/Summary/Summary.cpp +++ b/opm/parser/eclipse/EclipseState/Summary/Summary.cpp @@ -83,25 +83,25 @@ namespace Opm { } static inline std::array< int, 3 > dimensions( const EclipseGrid& grid ) { - return { + return {{ int( grid.getNX() ), int( grid.getNY() ), int( grid.getNZ() ) - }; + }}; } static inline std::array< int, 3 > getijk( const DeckRecord& record, int offset = 0 ) { - return { + return {{ record.getItem( offset + 0 ).get< int >( 0 ) - 1, record.getItem( offset + 1 ).get< int >( 0 ) - 1, record.getItem( offset + 2 ).get< int >( 0 ) - 1 - }; + }}; } static inline std::array< int, 3 > getijk( const Completion& completion ) { - return { completion.getI(), completion.getJ(), completion.getK() }; + return {{ completion.getI(), completion.getJ(), completion.getK() }}; } static inline std::vector< ERT::smspec_node > keywordB( From 92a55cb267be8c7a2d20aa442b73f395f7898161 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 14 Apr 2016 17:19:37 +0200 Subject: [PATCH 13/13] avoid reserved names for guard macros just like for macros that start and end with `__`, `clang++ -Weverything` likes to complain about macros which start and end with a single underscore. This is basically the same issue as Ensembles/ert#1048 --- opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Util/RecordVector.hpp | 4 ++-- opm/parser/eclipse/EclipseState/Util/Value.hpp | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp b/opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp index afd945837..f49b71a09 100644 --- a/opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef _FACEDIR_ -#define _FACEDIR_ +#ifndef OPM_FACEDIR_HPP +#define OPM_FACEDIR_HPP #include diff --git a/opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp b/opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp index b56235d8b..f35354db9 100644 --- a/opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef _MINPVMODE_ -#define _MINPVMODE_ +#ifndef OPM_MINPVMODE_HPP +#define OPM_MINPVMODE_HPP #include diff --git a/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp b/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp index a730c965f..13abf082c 100644 --- a/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef _PINCHMODE_ -#define _PINCHMODE_ +#ifndef OPM_PINCHMODE_HPP +#define OPM_PINCHMODE_HPP #include diff --git a/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp b/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp index 413730661..91aa299a0 100644 --- a/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.hpp @@ -18,8 +18,8 @@ */ -#ifndef _COLUMN_SCHEMA_HPP_ -#define _COLUMN_SCHEMA_HPP_ +#ifndef OPM_COLUMN_SCHEMA_HPP +#define OPM_COLUMN_SCHEMA_HPP #include #include diff --git a/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp b/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp index 72b2d66b6..5fa75ae4e 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableColumn.hpp @@ -18,8 +18,8 @@ */ -#ifndef _TABLE_COLUMN_HPP_ -#define _TABLE_COLUMN_HPP_ +#ifndef OPM_TABLE_COLUMN_HPP +#define OPM_TABLE_COLUMN_HPP #include #include diff --git a/opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp b/opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp index 3c5060713..2cb651944 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableEnums.hpp @@ -18,8 +18,8 @@ */ -#ifndef _TABLE_ENUMS_HPP_ -#define _TABLE_ENUMS_HPP_ +#ifndef OPM_TABLE_ENUMS_HPP +#define OPM_TABLE_ENUMS_HPP namespace Opm { namespace Table { diff --git a/opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp b/opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp index 27bdbfbef..f2fc23e8e 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp @@ -18,8 +18,8 @@ */ -#ifndef _TABLE_INDEX_HPP_ -#define _TABLE_INDEX_HPP_ +#ifndef OPM_TABLE_INDEX_HPP +#define OPM_TABLE_INDEX_HPP #include diff --git a/opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp b/opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp index 4ab214055..3e31100df 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp @@ -18,8 +18,8 @@ */ -#ifndef _TABLE_SCHEMA_HPP_ -#define _TABLE_SCHEMA_HPP_ +#ifndef OPM_TABLE_SCHEMA_HPP +#define OPM_TABLE_SCHEMA_HPP #include #include diff --git a/opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp b/opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp index d17b6cc86..796fe65e1 100644 --- a/opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp +++ b/opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef _ORDERED_MAP_ -#define _ORDERED_MAP_ +#ifndef OPM_ORDERED_MAP_HPP +#define OPM_ORDERED_MAP_HPP #include #include diff --git a/opm/parser/eclipse/EclipseState/Util/RecordVector.hpp b/opm/parser/eclipse/EclipseState/Util/RecordVector.hpp index e7a44d29b..d612f7728 100644 --- a/opm/parser/eclipse/EclipseState/Util/RecordVector.hpp +++ b/opm/parser/eclipse/EclipseState/Util/RecordVector.hpp @@ -18,8 +18,8 @@ */ -#ifndef _RECORD_VECTOR_ -#define _RECORD_VECTOR_ +#ifndef OPM_RECORD_VECTOR_HPP +#define OPM_RECORD_VECTOR_HPP #include #include diff --git a/opm/parser/eclipse/EclipseState/Util/Value.hpp b/opm/parser/eclipse/EclipseState/Util/Value.hpp index 5997bc852..1945a5f50 100644 --- a/opm/parser/eclipse/EclipseState/Util/Value.hpp +++ b/opm/parser/eclipse/EclipseState/Util/Value.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef _VALUE_ -#define _VALUE_ +#ifndef OPM_VALUE_HPP +#define OPM_VALUE_HPP #include #include