diff --git a/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp b/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp index 6a130d8e4..746f4d535 100644 --- a/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp +++ b/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp @@ -170,25 +170,23 @@ 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 = { "*" }; - const auto hasValue = []( const DeckKeyword& kw ) { return kw.getDataRecord().getDataItem().hasValue( 0 ); }; - const auto& patterns = keyword.size() > 0 && hasValue( keyword ) - ? keyword.getStringData() - : wildcard; + if (keyword.size() && hasValue(keyword)) { + for( const std::string& pattern : keyword.getStringData()) { + auto wells = schedule.getWellsMatching( pattern ); - for( const std::string& pattern : patterns ) { - auto wells = schedule.getWellsMatching( pattern ); + if( wells.empty() ) + handleMissingWell( parseContext, keyword.name(), pattern ); - if( wells.empty() ) - handleMissingWell( parseContext, keyword.name(), pattern ); - - for( const auto* well : wells ) - list.emplace_back( type, well->name(), keyword.name() ); - } + for( const auto* well : wells ) + list.emplace_back( type, well->name(), keyword.name() ); + } + } else + for (const auto* well : schedule.getWells()) + list.emplace_back(type, well->name(), keyword.name()); } inline void keywordG( std::vector< ERT::smspec_node >& list, diff --git a/tests/parser/SummaryConfigTests.cpp b/tests/parser/SummaryConfigTests.cpp index 6679ec1c1..5fdc8b351 100644 --- a/tests/parser/SummaryConfigTests.cpp +++ b/tests/parser/SummaryConfigTests.cpp @@ -30,6 +30,33 @@ using namespace Opm; +static Deck createDeck_no_wells( const std::string& summary ) { + Opm::Parser parser; + std::string input = + "START -- 0 \n" + "10 MAI 2007 / \n" + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "REGDIMS\n" + " 3/\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" + "SUMMARY\n" + + summary; + + return parser.parseString(input, ParseContext()); +} + + static Deck createDeck( const std::string& summary ) { Opm::Parser parser; std::string input = @@ -118,6 +145,17 @@ BOOST_AUTO_TEST_CASE(wells_all) { names.begin(), names.end() ); } +BOOST_AUTO_TEST_CASE(wells_missingI) { + ParseContext parseContext; + const auto input = "WWCT\n/\n"; + auto deck = createDeck_no_wells( input ); + parseContext.update(ParseContext::SUMMARY_UNKNOWN_WELL, InputError::THROW_EXCEPTION); + EclipseState state( deck, parseContext ); + Schedule schedule(deck, state.getInputGrid(), state.get3DProperties(), state.runspec().phases(), parseContext); + BOOST_CHECK_NO_THROW( SummaryConfig( deck, schedule, state.getTableManager( ), parseContext )); +} + + BOOST_AUTO_TEST_CASE(wells_select) { const auto input = "WWCT\n'W_1' 'WX2' /\n"; const auto summary = createSummary( input );