From 4b3c06cbcc96319b958c2a6b2f9c1fdbb9d6f715 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 8 Sep 2017 22:25:55 +0200 Subject: [PATCH] Fixed bug in time dependence of RFT configuration. --- .../eclipse/EclipseState/Schedule/Well.hpp | 7 +-- .../EclipseState/Schedule/Schedule.cpp | 50 +++--------------- .../eclipse/EclipseState/Schedule/Well.cpp | 51 ++++++++++++++----- .../SCHEDULE/SCHEDULE_WELLS2 | 10 ++++ .../integration/ScheduleCreateFromDeck.cpp | 7 ++- 5 files changed, 65 insertions(+), 60 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index cb6cb06dc..55919a8f3 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include namespace Opm { @@ -129,9 +130,9 @@ namespace Opm { int firstRFTOutput( ) const; bool getRFTActive(size_t time_step) const; - void setRFTActive(size_t time_step, bool value); + void updateRFTActive(size_t time_step, RFTConnections::RFTEnum mode); bool getPLTActive(size_t time_step) const; - void setPLTActive(size_t time_step, bool value); + void updatePLTActive(size_t time_step, PLTConnections::PLTEnum mode); int findWellFirstOpen(int startTimeStep) const; /* @@ -139,7 +140,7 @@ namespace Opm { WELSPECS, actually opening the well might be later. */ size_t firstTimeStep( ) const; - void setRFTForWellWhenFirstOpen(int numSteps,size_t currentStep); + void setRFTForWellWhenFirstOpen(size_t currentStep); static bool wellNameInWellNamePattern(const std::string& wellName, const std::string& wellNamePattern); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index acc868768..21acf25cb 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -1310,23 +1310,15 @@ namespace Opm { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - for( auto* well : getWells( wellNamePattern ) ) { - - well->setRFTActive(currentStep, true); - size_t numStep = m_timeMap.numTimesteps(); - if(currentStepsetRFTActive(currentStep+1, false); - } - } + for( auto* well : getWells( wellNamePattern ) ) + well->updateRFTActive( currentStep, RFTConnections::RFTEnum::YES); } - for( auto& well : this->m_wells ) { - well.setRFTForWellWhenFirstOpen(m_timeMap.numTimesteps(), currentStep); - } + for( auto& well : this->m_wells ) + well.setRFTForWellWhenFirstOpen( currentStep ); } void Schedule::handleWRFTPLT( const DeckKeyword& keyword, size_t currentStep) { - for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); @@ -1335,38 +1327,8 @@ namespace Opm { PLTConnections::PLTEnum PLTKey = PLTConnections::PLTEnumFromString(record.getItem("OUTPUT_PLT").getTrimmedString(0)); for( auto* well : getWells( wellNamePattern ) ) { - switch(RFTKey){ - case RFTConnections::RFTEnum::YES: - well->setRFTActive(currentStep, true); - break; - case RFTConnections::RFTEnum::REPT: - well->setRFTActive(currentStep, true); - break; - case RFTConnections::RFTEnum::TIMESTEP: - well->setRFTActive(currentStep, true); - break; - case RFTConnections::RFTEnum::FOPN: - well->setRFTForWellWhenFirstOpen(m_timeMap.numTimesteps(),currentStep); - break; - case RFTConnections::RFTEnum::NO: - well->setRFTActive(currentStep, false); - break; - } - - switch(PLTKey){ - case PLTConnections::PLTEnum::YES: - well->setPLTActive(currentStep, true); - break; - case PLTConnections::PLTEnum::REPT: - well->setPLTActive(currentStep, true); - break; - case PLTConnections::PLTEnum::TIMESTEP: - well->setPLTActive(currentStep, true); - break; - case PLTConnections::PLTEnum::NO: - well->setPLTActive(currentStep, false); - break; - } + well->updateRFTActive( currentStep, RFTKey ); + well->updatePLTActive( currentStep, PLTKey ); } } } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index b04006466..44e6eda18 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -393,8 +393,42 @@ namespace Opm { - void Well::setRFTActive(size_t time_step, bool value){ - m_rft.update(time_step, value); + void Well::updateRFTActive(size_t time_step, RFTConnections::RFTEnum mode) { + switch(mode) { + case RFTConnections::RFTEnum::YES: + m_rft.update_elm(time_step, true); + break; + case RFTConnections::RFTEnum::TIMESTEP: + m_rft.update_elm(time_step, true); + break; + case RFTConnections::RFTEnum::REPT: + m_rft.update(time_step, true); + break; + case RFTConnections::RFTEnum::FOPN: + setRFTForWellWhenFirstOpen(time_step); + break; + case RFTConnections::RFTEnum::NO: + m_rft.update(time_step, false); + break; + default: + break; + } + } + + void Well::updatePLTActive(size_t time_step, PLTConnections::PLTEnum mode){ + switch(mode) { + case PLTConnections::PLTEnum::YES: + m_plt.update_elm(time_step, true); + break; + case PLTConnections::PLTEnum::REPT: + m_plt.update(time_step, true); + break; + case PLTConnections::PLTEnum::NO: + m_plt.update(time_step, false); + break; + default: + break; + } } bool Well::getRFTActive(size_t time_step) const{ @@ -404,9 +438,6 @@ namespace Opm { bool Well::getPLTActive(size_t time_step) const{ return bool( m_plt.get(time_step) ); } - void Well::setPLTActive(size_t time_step, bool value){ - m_plt.update(time_step, value); - } /* The first report step where *either* RFT or PLT output is active. @@ -443,19 +474,15 @@ namespace Opm { return -1; } - void Well::setRFTForWellWhenFirstOpen(int numSteps,size_t currentStep){ + void Well::setRFTForWellWhenFirstOpen(size_t currentStep){ int time; if(getStatus(currentStep)==WellCommon::StatusEnum::OPEN ){ time = currentStep; }else { time = findWellFirstOpen(currentStep); } - if(time>-1){ - setRFTActive(time, true); - if(time < numSteps){ - setRFTActive(time+1, false); - } - } + if (time > -1) + updateRFTActive(time, RFTConnections::RFTEnum::YES); } WellCompletion::CompletionOrderEnum Well::getWellCompletionOrdering() const { diff --git a/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_WELLS2 b/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_WELLS2 index 3e05fe621..cbe614909 100644 --- a/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_WELLS2 +++ b/tests/parser/data/integration_tests/SCHEDULE/SCHEDULE_WELLS2 @@ -19,6 +19,11 @@ WELSPECS 'W_4' 'OP' 32 19 1* 'OIL' 7* / / +WRFTPLT + 'W_1' 'YES' 'NO' 'NO' / + 'W_2' 'REPT' 'NO' 'NO' / +/ + COMPDAT -- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro 'W_1' 30 37 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / @@ -51,6 +56,11 @@ TSTEP -- 4 TSTEP -- 5 10 / +WRFTPLT + 'W_2' 'NO' 'NO' 'NO' / +/ + + TSTEP -- 6 10 / diff --git a/tests/parser/integration/ScheduleCreateFromDeck.cpp b/tests/parser/integration/ScheduleCreateFromDeck.cpp index 89895e34a..3ef1b20da 100644 --- a/tests/parser/integration/ScheduleCreateFromDeck.cpp +++ b/tests/parser/integration/ScheduleCreateFromDeck.cpp @@ -191,7 +191,10 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK_EQUAL( 0 , well2->getProductionPropertiesCopy(8).ResVRate); BOOST_CHECK_EQUAL( WellCommon::SHUT , well2->getStatus(3)); - + BOOST_CHECK( !well2->getRFTActive( 2 ) ); + BOOST_CHECK( well2->getRFTActive( 3 ) ); + BOOST_CHECK( well2->getRFTActive( 4 ) ); + BOOST_CHECK( !well2->getRFTActive( 5 ) ); { const WellProductionProperties& prop3 = well2->getProductionProperties(3); BOOST_CHECK_EQUAL( WellProducer::ORAT , prop3.controlMode); @@ -221,6 +224,8 @@ BOOST_AUTO_TEST_CASE(WellTesting) { { auto* well1 = sched.getWell("W_1"); + BOOST_CHECK_EQUAL( well1->firstRFTOutput( ) , 3); + BOOST_CHECK( well1->getRFTActive( 3 ) ); BOOST_CHECK(well1->getProductionPropertiesCopy(0).predictionMode); BOOST_CHECK_EQUAL(0, well1->getProductionPropertiesCopy(0).OilRate);