Added FIP_PROBE and tests, we now accept FIPxxxx kws
This commit is contained in:
@@ -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" ),
|
||||
|
||||
@@ -36,6 +36,17 @@ namespace Opm {
|
||||
return kw;
|
||||
}
|
||||
|
||||
template<typename> 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<double>::GridProperties(const EclipseGrid& eclipseGrid,
|
||||
@@ -154,10 +165,10 @@ namespace Opm {
|
||||
return m_messages;
|
||||
}
|
||||
|
||||
|
||||
template< typename T >
|
||||
bool GridProperties<T>::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<T>(kw);
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
@@ -236,6 +247,9 @@ namespace Opm {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isFipxxx<T>(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<T>(keywordName))
|
||||
m_supportedKeywords.emplace(keywordName, SupportedKeywordInfo( keywordName , 1, "1" ));
|
||||
|
||||
insertKeyword( m_supportedKeywords.at( keywordName ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -174,8 +174,8 @@ namespace Opm {
|
||||
size_t nz = 0;
|
||||
const UnitSystem * m_deckUnitSystem = nullptr;
|
||||
MessageContainer m_messages;
|
||||
std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
|
||||
|
||||
mutable std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
|
||||
mutable storage m_properties;
|
||||
mutable std::set<std::string> m_autoGeneratedProperties;
|
||||
};
|
||||
|
||||
@@ -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) );
|
||||
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"name" : "FIPNUM" , "sections" : ["REGIONS"], "data" : {"value_type" : "INT"}}
|
||||
6
opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE
Normal file
6
opm/parser/share/keywords/000_Eclipse100/F/FIP_PROBE
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name" : "FIP_PROBE" ,
|
||||
"sections" : ["REGIONS"],
|
||||
"data" : {"value_type" : "INT"},
|
||||
"deck_name_regex" : "FIP.+"
|
||||
}
|
||||
Reference in New Issue
Block a user