From b8b5bd374b0841e8dd5fdbc40e34922a69ec3740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A5l=20Gr=C3=B8n=C3=A5s=20Drange?= Date: Tue, 10 Jan 2017 15:20:59 +0100 Subject: [PATCH] Added FIP_PROBE and tests, we now accept FIPxxxx kws --- .../EclipseState/Eclipse3DProperties.cpp | 1 - .../EclipseState/Grid/GridProperties.cpp | 22 +++++++++++++++++-- .../EclipseState/Grid/GridProperties.hpp | 2 +- .../tests/Eclipse3DPropertiesTests.cpp | 12 +++++++++- .../share/keywords/000_Eclipse100/F/FIPNUM | 1 - .../share/keywords/000_Eclipse100/F/FIP_PROBE | 6 +++++ 6 files changed, 38 insertions(+), 6 deletions(-) delete mode 100644 opm/parser/share/keywords/000_Eclipse100/F/FIPNUM create mode 100644 opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE diff --git a/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp b/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp index 1eaede393..dc020b7df 100644 --- a/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp +++ b/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp @@ -190,7 +190,6 @@ namespace Opm { return { GridProperties< int >::SupportedKeywordInfo( "ENDNUM" , 1, "1" ), GridProperties< int >::SupportedKeywordInfo( "EQLNUM" , 1, "1" ), - GridProperties< int >::SupportedKeywordInfo( "FIPNUM" , 1, "1" ), GridProperties< int >::SupportedKeywordInfo( "FLUXNUM", 1, "1" ), GridProperties< int >::SupportedKeywordInfo( "IMBNUM" , 1, "1" ), GridProperties< int >::SupportedKeywordInfo( "MISCNUM", 1, "1" ), diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp b/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp index 90ae3c614..ef2d27438 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp @@ -36,6 +36,17 @@ namespace Opm { return kw; } + template bool isFipxxx( const std::string& ) { return false; } + + template<> + bool isFipxxx< int >(const std::string& keyword) { + // FIPxxxx can be any keyword, e.g. FIPREG or FIPXYZ that has the pattern "FIP.+" + // However, it can not be FIPOWG as that is an actual keyword. + if (keyword.size() < 4 || keyword == "FIPOWG") { + return false; + } + return keyword[0] == 'F' && keyword[1] == 'I' && keyword[2] == 'P'; + } template <> GridProperties::GridProperties(const EclipseGrid& eclipseGrid, @@ -154,10 +165,10 @@ namespace Opm { return m_messages; } - template< typename T > bool GridProperties::supportsKeyword(const std::string& keyword) const { - return m_supportedKeywords.count( normalize( keyword ) ) > 0; + const std::string kw = normalize(keyword); + return m_supportedKeywords.count( kw ) > 0 || isFipxxx(kw); } template< typename T > @@ -236,6 +247,9 @@ namespace Opm { return true; } + if (isFipxxx(kw)) + m_supportedKeywords.emplace(kw, SupportedKeywordInfo( kw , 1, "1" )); + insertKeyword( m_supportedKeywords.at( kw ) ); return true; } @@ -545,6 +559,10 @@ namespace Opm { return false; // property already exists (if it is auto generated or not doesn't matter) else { m_autoGeneratedProperties.insert(keywordName); + + if (isFipxxx(keywordName)) + m_supportedKeywords.emplace(keywordName, SupportedKeywordInfo( keywordName , 1, "1" )); + insertKeyword( m_supportedKeywords.at( keywordName ) ); return true; } diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp index cb6fa72b9..3d1512300 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp @@ -174,8 +174,8 @@ namespace Opm { size_t nz = 0; const UnitSystem * m_deckUnitSystem = nullptr; MessageContainer m_messages; - std::unordered_map m_supportedKeywords; + mutable std::unordered_map m_supportedKeywords; mutable storage m_properties; mutable std::set m_autoGeneratedProperties; }; diff --git a/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp b/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp index ed2a2f9bb..4612b486d 100644 --- a/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp +++ b/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp @@ -321,16 +321,26 @@ BOOST_AUTO_TEST_CASE(getRegions) { "TOPS\n" "4*0.25 /\n" "REGIONS\n" + "FIPPGDX\n" + "2 1 1 2 /\n" + "FIPREG\n" + "3 2 3 2 /\n" "FIPNUM\n" "1 1 2 3 /\n"; Setup s( Opm::Parser().parseString(input, Opm::ParseContext() ) ); std::vector< int > ref = { 1, 2, 3 }; - const auto regions = s.props.getRegions( "FIPNUM" ); + const auto& regions = s.props.getRegions( "FIPNUM" ); BOOST_CHECK_EQUAL_COLLECTIONS( ref.begin(), ref.end(), regions.begin(), regions.end() ); BOOST_CHECK( s.props.getRegions( "EQLNUM" ).empty() ); + BOOST_CHECK( ! s.props.getRegions( "FIPPGDX" ).empty() ); + + const auto& fipreg = s.props.getRegions( "FIPREG" ); + BOOST_CHECK_EQUAL( 2, fipreg.at(0) ); + BOOST_CHECK_EQUAL( 3, fipreg.at(1) ); + } diff --git a/opm/parser/share/keywords/000_Eclipse100/F/FIPNUM b/opm/parser/share/keywords/000_Eclipse100/F/FIPNUM deleted file mode 100644 index cc9582cba..000000000 --- a/opm/parser/share/keywords/000_Eclipse100/F/FIPNUM +++ /dev/null @@ -1 +0,0 @@ -{"name" : "FIPNUM" , "sections" : ["REGIONS"], "data" : {"value_type" : "INT"}} diff --git a/opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE b/opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE new file mode 100644 index 000000000..64327dbe2 --- /dev/null +++ b/opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE @@ -0,0 +1,6 @@ +{ + "name" : "FIP_PROBE" , + "sections" : ["REGIONS"], + "data" : {"value_type" : "INT"}, + "deck_name_regex" : "FIP.+" +}