[Summary] W-keywords accept patterns

The W-family of keywords accept a pattern to expand, rather than just
names or defaulted-all. This is the actual behaviour, according to the
manual.
This commit is contained in:
Jørgen Kvalsvik 2016-07-18 14:44:00 +02:00
parent 3f98a747df
commit d98215ae40
2 changed files with 25 additions and 14 deletions

View File

@ -109,23 +109,24 @@ inline void keywordW( std::vector< ERT::smspec_node >& list,
const Schedule& schedule ) {
const auto type = ECL_SMSPEC_WELL_VAR;
static const std::vector< std::string > wildcard = { "*" };
if( keyword.size() == 0 ||
!keyword.getDataRecord().getDataItem().hasValue( 0 ) ) {
const auto hasValue = []( const DeckKeyword& kw ) {
return kw.getDataRecord().getDataItem().hasValue( 0 );
};
for( const auto& well : schedule.getWells() )
const auto& patterns = keyword.size() > 0 && hasValue( keyword )
? keyword.getStringData()
: wildcard;
for( const std::string& pattern : patterns ) {
auto wells = schedule.getWellsMatching( pattern );
if( wells.empty() )
handleMissingWell( parseContext, keyword.name(), pattern );
for( const auto* well : wells )
list.emplace_back( type, well->name(), keyword.name() );
return;
}
const auto& item = keyword.getDataRecord().getDataItem();
for( const std::string& well : item.getData< std::string >() ) {
if( schedule.hasWell( well ) )
list.emplace_back( type, well, keyword.name() );
else
handleMissingWell( parseContext, keyword.name(), well );
}
}

View File

@ -125,6 +125,16 @@ BOOST_AUTO_TEST_CASE(wells_select) {
names.begin(), names.end() );
}
BOOST_AUTO_TEST_CASE(wells_pattern) {
const auto input = "WWCT\n'W*' /\n";
const auto summary = createSummary( input );
const auto wells = { "WX2", "W_1", "W_3" };
const auto names = sorted_names( summary );
BOOST_CHECK_EQUAL_COLLECTIONS(
wells.begin(), wells.end(),
names.begin(), names.end() );
}
BOOST_AUTO_TEST_CASE(fields) {
const auto input = "FOPT\n";