From 183fd4eabb885b9780dfad5dc3204a01e1e76d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Petter=20=C3=98ren=20Hauge?= Date: Mon, 23 Apr 2018 12:45:57 +0200 Subject: [PATCH] Add INVALID_WELL context for WCONPROD Handle invalid wellpatterns for WCONPROD. Given a deck with: ---- WELSPECS 'PROD' 'G1' 10 10 8400 'OIL' / / COMPDAT 'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 / / WCONPROD 'SOMETHINGELSE' 'OPEN' 'ORAT' 20000 4* 1000 / / ---- OPM will now by default abort and inform the user that no well match "SOMETHINGELSE". --- .../eclipse/EclipseState/Schedule/Schedule.hpp | 6 +++--- .../eclipse/EclipseState/Schedule/Schedule.cpp | 18 ++++++++++-------- tests/parser/ParseContextTests.cpp | 11 +++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index b04c87ce0..a95212cfd 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -146,9 +146,9 @@ namespace Opm void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder); void handleCOMPORD(const ParseContext& parseContext, const DeckKeyword& compordKeyword, size_t currentStep); void handleWELSPECS( const SCHEDULESection&, size_t, size_t ); - void handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode); - void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep); - void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep); + void handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext); + void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); + void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleWGRUPCON( const DeckKeyword& keyword, size_t currentStep); void handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid, const Eclipse3DProperties& eclipseProperties, const ParseContext& parseContext); void handleCOMPLUMP( 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 df363745a..cf4e596a2 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -166,10 +166,10 @@ namespace Opm { handleWHISTCTL(parseContext, keyword); else if (keyword.name() == "WCONHIST") - handleWCONHIST(keyword, currentStep); + handleWCONHIST(keyword, currentStep, parseContext); else if (keyword.name() == "WCONPROD") - handleWCONPROD(keyword, currentStep); + handleWCONPROD(keyword, currentStep, parseContext); else if (keyword.name() == "WCONINJE") handleWCONINJE(section, keyword, currentStep); @@ -475,7 +475,7 @@ namespace Opm { } } - void Schedule::handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode) { + void Schedule::handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); @@ -484,8 +484,10 @@ namespace Opm { WellCommon::StatusFromString(record.getItem("STATUS").getTrimmedString(0)); auto wells = getWells(wellNamePattern); + if (wells.empty()) + InvalidWellPattern(wellNamePattern, parseContext, keyword); - for( auto* well : getWells( wellNamePattern ) ) { + for( auto* well : wells ) { WellProductionProperties properties; @@ -528,12 +530,12 @@ namespace Opm { } - void Schedule::handleWCONHIST(const DeckKeyword& keyword, size_t currentStep) { - handleWCONProducer(keyword, currentStep, false); + void Schedule::handleWCONHIST( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { + handleWCONProducer(keyword, currentStep, false, parseContext); } - void Schedule::handleWCONPROD( const DeckKeyword& keyword, size_t currentStep) { - handleWCONProducer(keyword, currentStep, true); + void Schedule::handleWCONPROD( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { + handleWCONProducer( keyword, currentStep, true, parseContext); } static Opm::Value getValueItem( const DeckItem& item ){ diff --git a/tests/parser/ParseContextTests.cpp b/tests/parser/ParseContextTests.cpp index b0a12d3a4..a75b95dba 100644 --- a/tests/parser/ParseContextTests.cpp +++ b/tests/parser/ParseContextTests.cpp @@ -515,6 +515,17 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { )"; testSamples.push_back(testSample); + // Invalid well name in WCONPROD + testSample = R"( + COMPDAT + 'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONPROD + 'SOMETHINGELSE' 'OPEN' 'ORAT' 20000 4* 1000 / + / + )"; + testSamples.push_back(testSample); + std::string deckinput; for (std::string sample : testSamples) {