diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 80921f4ca..ad32dfdd3 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -164,9 +164,9 @@ namespace Opm void handleWCONINJH( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); 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); + void handleGCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); + void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); + void handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleTUNING( const DeckKeyword& keyword, size_t currentStep); void handleGRUPTREE( 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 29e72b363..c3062bf75 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -214,13 +214,13 @@ namespace Opm { handleGRUPNET(keyword, currentStep); else if (keyword.name() == "GCONINJE") - handleGCONINJE(section, keyword, currentStep); + handleGCONINJE(section, keyword, currentStep, parseContext); else if (keyword.name() == "GCONPROD") - handleGCONPROD(keyword, currentStep); + handleGCONPROD(keyword, currentStep, parseContext); else if (keyword.name() == "GEFAC") - handleGEFAC(keyword, currentStep); + handleGEFAC(keyword, currentStep, parseContext); else if (keyword.name() == "TUNING") handleTUNING(keyword, currentStep); @@ -1141,11 +1141,14 @@ namespace Opm { } } - void Schedule::handleGCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleGCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0); auto groups = getGroups ( groupNamePattern ); + if (groups.empty()) + invalidNamePattern(groupNamePattern, parseContext, keyword); + for (auto* group : groups){ { Phase phase = get_phase( record.getItem("PHASE").getTrimmedString(0) ); @@ -1173,11 +1176,14 @@ namespace Opm { } } - void Schedule::handleGCONPROD( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleGCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0); auto groups = getGroups ( groupNamePattern ); + if (groups.empty()) + invalidNamePattern(groupNamePattern, parseContext, keyword); + for (auto* group : groups){ { GroupProduction::ControlEnum controlMode = GroupProduction::ControlEnumFromString( record.getItem("CONTROL_MODE").getTrimmedString(0) ); @@ -1199,11 +1205,14 @@ namespace Opm { } - void Schedule::handleGEFAC( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleGEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0); auto groups = getGroups ( groupNamePattern ); + if (groups.empty()) + invalidNamePattern(groupNamePattern, parseContext, keyword); + for (auto* group : groups){ group->setGroupEfficiencyFactor(currentStep, record.getItem("EFFICIENCY_FACTOR").get< double >(0)); diff --git a/tests/parser/ParseContextTests.cpp b/tests/parser/ParseContextTests.cpp index dc58807bc..5f6da3459 100644 --- a/tests/parser/ParseContextTests.cpp +++ b/tests/parser/ParseContextTests.cpp @@ -673,6 +673,30 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { 'SOMETHINGELSE' 0.5 / / )"; + + testSamples.push_back(testSample); + // Invalid group name in GCONPROD + testSample = R"( + GCONPROD + 'SOMETHINGELSE' 'ORAT' 20000 / + / + )"; + testSamples.push_back(testSample); + + // Invalid group name in GEFAC + testSample = R"( + GEFAC + 'SOMETHINGELSE' 0.5 / + / + )"; + testSamples.push_back(testSample); + + // Invalid group name in GCONINJE + testSample = R"( + GCONINJE + 'SOMETHINGELSE' 'WAT' 'RATE' 20000 / + / + )"; testSamples.push_back(testSample); std::string deckinput;