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.
This commit is contained in:
parent
b778beb507
commit
dbbbd2e8f7
@ -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 {};
|
||||
}
|
||||
|
@ -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() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user