diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 613600570..4d95c9cfc 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -160,8 +160,8 @@ namespace Opm void handleWTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleWINJTEMP( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleWCONINJH( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); - void handleWELOPEN( const DeckKeyword& keyword, size_t currentStep ); - void handleWELTARG( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep); + void handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext ); + void handleWELTARG( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleGCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep); void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep); void handleGEFAC( const DeckKeyword& keyword, size_t currentStep); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 0d5ad4a03..5c8935235 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -202,10 +202,10 @@ namespace Opm { handleCOMPSEGS(keyword, currentStep); else if (keyword.name() == "WELOPEN") - handleWELOPEN(keyword, currentStep); + handleWELOPEN(keyword, currentStep, parseContext); else if (keyword.name() == "WELTARG") - handleWELTARG(section, keyword, currentStep); + handleWELTARG(section, keyword, currentStep, parseContext); else if (keyword.name() == "GRUPTREE") handleGRUPTREE(keyword, currentStep); @@ -913,7 +913,7 @@ namespace Opm { } } - void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep ) { + void Schedule::handleWELOPEN( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext ) { auto all_defaulted = []( const DeckRecord& rec ) { auto defaulted = []( const DeckItem& item ) { @@ -926,16 +926,21 @@ namespace Opm { constexpr auto open = WellCommon::StatusEnum::OPEN; for( const auto& record : keyword ) { - const auto& wellname = record.getItem( "WELL" ).getTrimmedString(0); + const auto& wellNamePattern = record.getItem( "WELL" ).getTrimmedString(0); const auto& status_str = record.getItem( "STATUS" ).getTrimmedString( 0 ); + auto wells = getWells( wellNamePattern ); + + if (wells.empty()) + InvalidWellPattern( wellNamePattern, parseContext, keyword); + /* if all records are defaulted or just the status is set, only * well status is updated */ if( all_defaulted( record ) ) { const auto status = WellCommon::StatusFromString( status_str ); - for( auto* well : getWells( wellname ) ) { + for( auto* well : wells ) { if( status == open && !well->canOpen(currentStep) ) { auto days = m_timeMap.getTimePassedUntil( currentStep ) / (60 * 60 * 24); std::string msg = "Well " + well->name() @@ -985,7 +990,7 @@ namespace Opm { return { completion, status }; }; - for( auto* well : getWells( wellname ) ) { + for( auto* well : wells ) { CompletionSet new_completions; for( const auto& c : well->getCompletions( currentStep ) ) new_completions.add( new_completion( c ) ); @@ -1008,7 +1013,10 @@ namespace Opm { WCONxxxx keyword). */ - void Schedule::handleWELTARG( const SCHEDULESection& section , const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWELTARG( const SCHEDULESection& section , + const DeckKeyword& keyword, + size_t currentStep, + const ParseContext& parseContext) { Opm::UnitSystem unitSystem = section.unitSystem(); double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time").getSIScaling(); double siFactorG = unitSystem.parse("GasSurfaceVolume/Time").getSIScaling(); @@ -1023,9 +1031,7 @@ namespace Opm { const auto wells = getWells( wellNamePattern ); if( wells.empty() ) - throw std::invalid_argument( - wellNamePattern + " does not match any wells. " + - "Specify wells with the WCONxxxx keywords." ); + InvalidWellPattern( wellNamePattern, parseContext, keyword); for( auto* well : wells ) { if(well->isProducer(currentStep)){ diff --git a/tests/parser/ParseContextTests.cpp b/tests/parser/ParseContextTests.cpp index ebe709bee..ee83253c4 100644 --- a/tests/parser/ParseContextTests.cpp +++ b/tests/parser/ParseContextTests.cpp @@ -616,6 +616,36 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { )"; testSamples.push_back(testSample); + // Invalid well name in WELOPEN + testSample = R"( + COMPDAT + 'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONINJE + 'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* / + / + DATES + 15 OKT 2008 / + / + WELOPEN + 'SOMETHINGELSE' / + / + )"; + testSamples.push_back(testSample); + + // Invalid well name in WELTARG + testSample = R"( + COMPDAT + 'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONHIST + 'PROD' 'OPEN' 'ORAT' 20000 4* 1000 / + / + WELTARG + 'SOMETHINGELSE' 'ORAT' 15000 / + / + )"; + testSamples.push_back(testSample); std::string deckinput;