From 5144456aa45909a82317340a7f5b0beada927f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 4 Jul 2019 09:08:54 +0200 Subject: [PATCH] Address review comments. - Use const reference to the dynamic state in handleWFOAM() and handleWPOLYMER(). - Throw if trying to set foam or polymer injection properties on a production well. - Update some tests that failed due to the point above. --- .../parser/eclipse/EclipseState/Schedule/Schedule.cpp | 4 ++-- .../eclipse/EclipseState/Schedule/Well/Well2.cpp | 10 ++++++++-- tests/parser/ScheduleTests.cpp | 6 ++++++ tests/summary_deck.DATA | 7 +++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index b1f463ee9..e5eb342fa 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -954,7 +954,7 @@ namespace Opm { invalidNamePattern(wellNamePattern, parseContext, errors, keyword); for (const auto& well_name : well_names) { - auto& dynamic_state = this->wells_static.at(well_name); + const auto& dynamic_state = this->wells_static.at(well_name); auto well2 = std::make_shared(*dynamic_state[currentStep]); auto foam_properties = std::make_shared(well2->getFoamProperties()); foam_properties->handleWFOAM(record); @@ -974,7 +974,7 @@ namespace Opm { for( const auto& well_name : well_names) { { - auto& dynamic_state = this->wells_static.at(well_name); + const auto& dynamic_state = this->wells_static.at(well_name); auto well2 = std::make_shared(*dynamic_state[currentStep]); auto polymer_properties = std::make_shared( well2->getPolymerProperties() ); polymer_properties->handleWPOLYMER(record); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp index 5b78b7d1e..8077c7cfa 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp @@ -136,9 +136,12 @@ bool Well2::updateWellGuideRate(double guide_rate_arg) { bool Well2::updateFoamProperties(std::shared_ptr foam_properties_arg) { + if (this->producer) { + throw std::runtime_error("Not allowed to set foam injection properties for well " + name() + + " since it is a production well"); + } if (*this->foam_properties != *foam_properties_arg) { this->foam_properties = foam_properties_arg; - this->producer = false; return true; } @@ -147,9 +150,12 @@ bool Well2::updateFoamProperties(std::shared_ptr foam_proper bool Well2::updatePolymerProperties(std::shared_ptr polymer_properties_arg) { + if (this->producer) { + throw std::runtime_error("Not allowed to set polymer injection properties for well " + name() + + " since it is a production well"); + } if (*this->polymer_properties != *polymer_properties_arg) { this->polymer_properties = polymer_properties_arg; - this->producer = false; return true; } diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 66f4d3581..844a74f39 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -3002,6 +3002,9 @@ BOOST_AUTO_TEST_CASE(POLYINJ_TEST) { "WELSPECS\n" "'INJE01' 'I' 1 1 1 'WATER' /\n" "/\n" + "WCONINJE\n" + "'INJE01' 'WATER' 'OPEN' 'RATE' 800.00 1* 1000 /\n" + "/\n" "TSTEP\n" " 1/\n" "WPOLYMER\n" @@ -3066,6 +3069,9 @@ BOOST_AUTO_TEST_CASE(WFOAM_TEST) { "WELSPECS\n" "'INJE01' 'I' 1 1 1 'WATER' /\n" "/\n" + "WCONINJE\n" + "'INJE01' 'GAS' 'OPEN' 'RATE' 80000.00 1* 1000 /\n" + "/\n" "TSTEP\n" " 1/\n" "WFOAM\n" diff --git a/tests/summary_deck.DATA b/tests/summary_deck.DATA index 3c9f8dec2..fdf252e9d 100644 --- a/tests/summary_deck.DATA +++ b/tests/summary_deck.DATA @@ -721,10 +721,6 @@ COMPDAT W_6 0 0 2 2 2* 1* 2* 0.7 / -- Active index: 2 / -WPOLYMER -'W_3' 1.5 1.0 / -/ - WCONHIST -- history rates are set so that W_1 produces 1, W_2 produces 2 etc. -- index.offset. @@ -738,6 +734,9 @@ WCONINJH W_3 WATER STOP 30.0 2.1 2.2 / / +WPOLYMER +'W_3' 1.5 1.0 / +/ WCONINJH -- Injection historical rates (water only, as we only support pure injectors) W_6 GAS STOP 30000.0 /