From 427833b0890c3cac38fbf14e3ff40bcaeab25df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Petter=20=C3=98ren=20Hauge?= Date: Thu, 3 May 2018 09:34:54 +0200 Subject: [PATCH] Add INVALID_WELLS to WECON & WEFAC --- .../EclipseState/Schedule/Schedule.hpp | 4 +-- .../EclipseState/Schedule/Schedule.cpp | 20 +++++++++---- tests/parser/ParseContextTests.cpp | 28 +++++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index 4d95c9cfc..c87d13858 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -165,7 +165,7 @@ namespace Opm 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 handleWEFAC( const DeckKeyword& keyword, size_t currentStep); + 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); void handleGRUPNET( const DeckKeyword& keyword, size_t currentStep); @@ -175,7 +175,7 @@ namespace Opm void handleDRSDT( const DeckKeyword& keyword, size_t currentStep); void handleDRVDT( const DeckKeyword& keyword, size_t currentStep); void handleVAPPARS( const DeckKeyword& keyword, size_t currentStep); - void handleWECON( const DeckKeyword& keyword, size_t currentStep); + void handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext); void handleWHISTCTL(const ParseContext& parseContext, const DeckKeyword& keyword); void handleMESSAGES(const DeckKeyword& keyword, size_t currentStep); void handleVFPPROD(const DeckKeyword& vfpprodKeyword, const UnitSystem& unit_system, size_t currentStep); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 5c8935235..e06626b95 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -250,13 +250,13 @@ namespace Opm { handleVAPPARS(keyword, currentStep); else if (keyword.name() == "WECON") - handleWECON(keyword, currentStep); + handleWECON(keyword, currentStep, parseContext); else if (keyword.name() == "MESSAGES") handleMESSAGES(keyword, currentStep); else if (keyword.name() == "WEFAC") - handleWEFAC(keyword, currentStep); + handleWEFAC(keyword, currentStep, parseContext); else if (keyword.name() == "VFPINJ") handleVFPINJ(keyword, unit_system, currentStep); @@ -726,23 +726,31 @@ namespace Opm { - void Schedule::handleWECON( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWECON( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); WellEconProductionLimits econ_production_limits(record); + const auto wells = getWells( wellNamePattern ); - for( auto* well : getWells( wellNamePattern ) ) { + if (wells.empty()) + InvalidWellPattern(wellNamePattern, parseContext, keyword); + + for( auto* well : wells ) { well->setEconProductionLimits(currentStep, econ_production_limits); } } } - void Schedule::handleWEFAC( const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELLNAME").getTrimmedString(0); const double& efficiencyFactor = record.getItem("EFFICIENCY_FACTOR").get< double >(0); + const auto wells = getWells( wellNamePattern ); - for( auto* well : getWells( wellNamePattern ) ) { + if (wells.empty()) + InvalidWellPattern(wellNamePattern, parseContext, keyword); + + for( auto* well : wells ) { well->setEfficiencyFactor(currentStep, efficiencyFactor); } } diff --git a/tests/parser/ParseContextTests.cpp b/tests/parser/ParseContextTests.cpp index ee83253c4..c4e2c9987 100644 --- a/tests/parser/ParseContextTests.cpp +++ b/tests/parser/ParseContextTests.cpp @@ -647,6 +647,34 @@ BOOST_AUTO_TEST_CASE( test_invalid_wtemplate_config ) { )"; testSamples.push_back(testSample); + // Invalid well name in WECON + testSample = R"( + COMPDAT + 'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONPROD + 'PROD' 'OPEN' 'ORAT' 20000 4* 1000 / + / + WECON + 'SOMETHINGELSE' 15000 / + / + )"; + testSamples.push_back(testSample); + + // Invalid well name in WEFAC + testSample = R"( + COMPDAT + 'PROD' 10 10 3 3 'OPEN' 1* 1* 0.5 / + / + WCONPROD + 'PROD' 'OPEN' 'ORAT' 20000 4* 1000 / + / + WEFAC + 'SOMETHINGELSE' 0.5 / + / + )"; + testSamples.push_back(testSample); + std::string deckinput; for (std::string sample : testSamples) {