diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index b4c6a4f98..613600570 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -155,8 +155,8 @@ namespace Opm void handleWELSEGS( const DeckKeyword& keyword, size_t currentStep); void handleCOMPSEGS( const DeckKeyword& keyword, size_t currentStep); void handleWCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); - void handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep); - void handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep); + void handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); + void handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); 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); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 733ba0bd1..0d5ad4a03 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -175,10 +175,10 @@ namespace Opm { handleWCONINJE(section, keyword, currentStep, parseContext); else if (keyword.name() == "WPOLYMER") - handleWPOLYMER(keyword, currentStep); + handleWPOLYMER(keyword, currentStep, parseContext); else if (keyword.name() == "WSOLVENT") - handleWSOLVENT(keyword, currentStep); + handleWSOLVENT(keyword, currentStep, parseContext); else if (keyword.name() == "WTEMP") handleWTEMP(keyword, currentStep, parseContext); @@ -695,11 +695,15 @@ namespace Opm { } - void Schedule::handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); + const auto wells = getWells( wellNamePattern ); - for( auto* well : getWells( wellNamePattern ) ) { + if (wells.empty()) + InvalidWellPattern(wellNamePattern, parseContext, keyword); + + for( auto* well : wells) { WellPolymerProperties properties(well->getPolymerPropertiesCopy(currentStep)); properties.m_polymerConcentration = record.getItem("POLYMER_CONCENTRATION").getSIDouble(0); @@ -745,12 +749,16 @@ namespace Opm { } - void Schedule::handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); + const auto wells = getWells( wellNamePattern ); - for( auto* well : getWells( wellNamePattern ) ) { + if (wells.empty()) + InvalidWellPattern(wellNamePattern, parseContext, keyword); + + for( auto* well : wells) { WellInjectionProperties injectionProperties = well->getInjectionProperties( currentStep ); if (well->isInjector( currentStep ) && injectionProperties.injectorType == WellInjector::GAS) { double fraction = record.getItem("SOLVENT_FRACTION").get< double >(0); diff --git a/tests/parser/ParseContextTests.cpp b/tests/parser/ParseContextTests.cpp index 77dfabb82..ebe709bee 100644 --- a/tests/parser/ParseContextTests.cpp +++ b/tests/parser/ParseContextTests.cpp @@ -474,7 +474,7 @@ BOOST_AUTO_TEST_CASE(test_1arg_constructor) { } BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { - const std::string defDeckString = R"( + const std::string defDeckString = R"( START -- 0 10 'JAN' 2000 / RUNSPEC @@ -582,6 +582,41 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { )"; testSamples.push_back(testSample); + // Invalid well name in WSOLVENT + testSample = R"( + COMPDAT + 'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONINJE + 'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* / + / + DATES + 15 OKT 2008 / + / + WSOLVENT + 'SOMETHINGELSE' 1.0 / + / + )"; + testSamples.push_back(testSample); + + // Invalid well name in WPOLYMER + testSample = R"( + COMPDAT + 'INJ' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONINJE + 'INJ' 'WATER' 'OPEN' 'RATE' 20000 4* / + / + DATES + 15 OKT 2008 / + / + WPOLYMER + 'SOMETHINGELSE' 1.0 0.0 / + / + )"; + testSamples.push_back(testSample); + + std::string deckinput; for (std::string sample : testSamples) {