From 82accba45bfa431cfd1311250226368a7f822c42 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 26 Aug 2019 13:11:15 +0200 Subject: [PATCH] Move injection control enum to Well2 class --- .../EclipseState/Schedule/ScheduleEnums.hpp | 22 --------- .../EclipseState/Schedule/Well/Well2.hpp | 45 +++++++++++++----- src/opm/output/eclipse/AggregateWellData.cpp | 4 +- .../EclipseState/Schedule/Schedule.cpp | 4 +- .../EclipseState/Schedule/ScheduleEnums.cpp | 33 +------------ .../EclipseState/Schedule/Well/Well2.cpp | 34 +++++++++++++- .../Schedule/Well/WellInjectionProperties.cpp | 34 +++++++------- tests/parser/ScheduleTests.cpp | 46 +++++++++---------- tests/parser/WellTests.cpp | 40 ++++++++-------- .../integration/ScheduleCreateFromDeck.cpp | 18 ++++---- 10 files changed, 140 insertions(+), 140 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp index f94cfdbd9..274d2d542 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp @@ -84,28 +84,6 @@ namespace Opm { } - namespace WellInjector { - - enum ControlModeEnum { - RATE = 1 , - RESV = 2 , - BHP = 4 , - THP = 8 , - GRUP = 16 , - CMODE_UNDEFINED = 512 - }; - /* - The elements in this enum are used as bitmasks to keep track - of which controls are present, i.e. the 2^n structure must - be intact. - */ - - - - const std::string ControlMode2String( ControlModeEnum enumValue ); - ControlModeEnum ControlModeFromString( const std::string& stringValue ); - } - namespace WellProducer { diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp index 3aba1eb9d..8af22161e 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp @@ -78,6 +78,24 @@ public: static InjectorType InjectorTypeFromString( const std::string& stringValue ); + /* + The elements in this enum are used as bitmasks to keep track + of which controls are present, i.e. the 2^n structure must + be intact. + */ + enum class InjectorCMode : int{ + RATE = 1 , + RESV = 2 , + BHP = 4 , + THP = 8 , + GRUP = 16 , + CMODE_UNDEFINED = 512 + }; + static const std::string InjectorCMode2String( InjectorCMode enumValue ); + static InjectorCMode InjectorCModeFromString( const std::string& stringValue ); + + + struct InjectionControls { public: InjectionControls(int controls_arg) : @@ -89,16 +107,17 @@ public: InjectorType injector_type; - WellInjector::ControlModeEnum cmode; + InjectorCMode cmode; double surface_rate; double reservoir_rate; double temperature; int vfp_table_number; bool prediction_mode; - bool hasControl(WellInjector::ControlModeEnum cmode_arg) const { - return (this->controls & cmode_arg) != 0; + bool hasControl(InjectorCMode cmode_arg) const { + return (this->controls & static_cast(cmode_arg)) != 0; } + private: int controls; }; @@ -118,7 +137,7 @@ public: bool predictionMode; int injectionControls; Well2::InjectorType injectorType; - WellInjector::ControlModeEnum controlMode; + InjectorCMode controlMode; bool operator==(const WellInjectionProperties& other) const; bool operator!=(const WellInjectionProperties& other) const; @@ -127,21 +146,23 @@ public: void handleWELTARG(WellTarget::ControlModeEnum cmode, double newValue, double siFactorG, double siFactorL, double siFactorP); void handleWCONINJE(const DeckRecord& record, bool availableForGroupControl, const std::string& well_name); void handleWCONINJH(const DeckRecord& record, bool is_producer, const std::string& well_name); - bool hasInjectionControl(WellInjector::ControlModeEnum controlModeArg) const { - if (injectionControls & controlModeArg) + bool hasInjectionControl(InjectorCMode controlModeArg) const { + if (injectionControls & static_cast(controlModeArg)) return true; else return false; } - void dropInjectionControl(WellInjector::ControlModeEnum controlModeArg) { - if ((injectionControls & controlModeArg) != 0) - injectionControls -= controlModeArg; + void dropInjectionControl(InjectorCMode controlModeArg) { + auto int_arg = static_cast(controlModeArg); + if ((injectionControls & int_arg) != 0) + injectionControls -= int_arg; } - void addInjectionControl(WellInjector::ControlModeEnum controlModeArg) { - if ((injectionControls & controlModeArg) == 0) - injectionControls += controlModeArg; + void addInjectionControl(InjectorCMode controlModeArg) { + auto int_arg = static_cast(controlModeArg); + if ((injectionControls & int_arg) == 0) + injectionControls += int_arg; } void resetDefaultHistoricalBHPLimit(); diff --git a/src/opm/output/eclipse/AggregateWellData.cpp b/src/opm/output/eclipse/AggregateWellData.cpp index 6cbb48c57..17c4f0720 100644 --- a/src/opm/output/eclipse/AggregateWellData.cpp +++ b/src/opm/output/eclipse/AggregateWellData.cpp @@ -172,7 +172,7 @@ namespace { const auto wmctl = controls.cmode; const auto wtype = controls.injector_type; - using CMode = ::Opm::WellInjector::ControlModeEnum; + using CMode = ::Opm::Well2::InjectorCMode; using WType = ::Opm::Well2::InjectorType; switch (wmctl) { @@ -513,7 +513,7 @@ namespace { else if (well.isInjector()) { const auto& ic = well.injectionControls(smry); - using IP = ::Opm::WellInjector::ControlModeEnum; + using IP = ::Opm::Well2::InjectorCMode; using IT = ::Opm::Well2::InjectorType; if (ic.hasControl(IP::RATE)) { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 735b40c4a..dadae110a 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -916,14 +916,14 @@ namespace { "This well will be closed at " + std::to_string ( m_timeMap.getTimePassedUntil(currentStep) / (60*60*24) ) + " days"; if (injection->surfaceInjectionRate.is()) { - if (injection->hasInjectionControl(WellInjector::RATE) && injection->surfaceInjectionRate.get() == 0) { + if (injection->hasInjectionControl(Well2::InjectorCMode::RATE) && injection->surfaceInjectionRate.get() == 0) { OpmLog::note(msg); updateWellStatus( well_name, currentStep, Well2::Status::SHUT ); } } if (injection->reservoirInjectionRate.is()) { - if (injection->hasInjectionControl(WellInjector::RESV) && injection->reservoirInjectionRate.get() == 0) { + if (injection->hasInjectionControl(Well2::InjectorCMode::RESV) && injection->reservoirInjectionRate.get() == 0) { OpmLog::note(msg); updateWellStatus( well_name, currentStep, Well2::Status::SHUT ); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp index f73bc9fb0..2934bee19 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp @@ -347,38 +347,7 @@ namespace Opm { namespace WellInjector { /*****************************************************************/ - const std::string ControlMode2String( ControlModeEnum enumValue ) { - switch( enumValue ) { - case RESV: - return "RESV"; - case RATE: - return "RATE"; - case BHP: - return "BHP"; - case THP: - return "THP"; - case GRUP: - return "GRUP"; - default: - throw std::invalid_argument("unhandled enum value"); - } - } - - ControlModeEnum ControlModeFromString( const std::string& stringValue ) { - if (stringValue == "RATE") - return RATE; - else if (stringValue == "RESV") - return RESV; - else if (stringValue == "BHP") - return BHP; - else if (stringValue == "THP") - return THP; - else if (stringValue == "GRUP") - return GRUP; - else - throw std::invalid_argument("Unknown enum state string: " + stringValue ); - } - + } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp index 7aa42717e..51206e19b 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well2.cpp @@ -176,7 +176,7 @@ void Well2::switchToProducer() { auto p = std::make_shared(this->getInjectionProperties()); p->BHPLimit.reset( 0 ); - p->dropInjectionControl( Opm::WellInjector::BHP ); + p->dropInjectionControl( Opm::Well2::InjectorCMode::BHP ); this->updateInjection( p ); this->updateProducer(true); } @@ -842,5 +842,37 @@ Well2::InjectorType Well2::InjectorTypeFromString( const std::string& stringValu throw std::invalid_argument("Unknown enum state string: " + stringValue ); } +const std::string Well2::InjectorCMode2String( InjectorCMode enumValue ) { + switch( enumValue ) { + case InjectorCMode::RESV: + return "RESV"; + case InjectorCMode::RATE: + return "RATE"; + case InjectorCMode::BHP: + return "BHP"; + case InjectorCMode::THP: + return "THP"; + case InjectorCMode::GRUP: + return "GRUP"; + default: + throw std::invalid_argument("unhandled enum value"); + } +} + + +Well2::InjectorCMode Well2::InjectorCModeFromString(const std::string &stringValue) { + if (stringValue == "RATE") + return InjectorCMode::RATE; + else if (stringValue == "RESV") + return InjectorCMode::RESV; + else if (stringValue == "BHP") + return InjectorCMode::BHP; + else if (stringValue == "THP") + return InjectorCMode::THP; + else if (stringValue == "GRUP") + return InjectorCMode::GRUP; + else + throw std::invalid_argument("Unknown enum state string: " + stringValue); +} } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp index 787a11845..825e145fe 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp @@ -38,7 +38,7 @@ namespace Opm { Well2::WellInjectionProperties::WellInjectionProperties(const std::string& wname) : name(wname), injectorType(InjectorType::WATER), - controlMode(WellInjector::CMODE_UNDEFINED) + controlMode(InjectorCMode::CMODE_UNDEFINED) { temperature= Metric::TemperatureOffset @@ -57,23 +57,23 @@ namespace Opm { if (!record.getItem("RATE").defaultApplied(0)) { this->surfaceInjectionRate = record.getItem("RATE").get(0); - this->addInjectionControl(WellInjector::RATE); + this->addInjectionControl(InjectorCMode::RATE); } else - this->dropInjectionControl(WellInjector::RATE); + this->dropInjectionControl(InjectorCMode::RATE); if (!record.getItem("RESV").defaultApplied(0)) { this->reservoirInjectionRate = record.getItem("RESV").get(0); - this->addInjectionControl(WellInjector::RESV); + this->addInjectionControl(InjectorCMode::RESV); } else - this->dropInjectionControl(WellInjector::RESV); + this->dropInjectionControl(InjectorCMode::RESV); if (!record.getItem("THP").defaultApplied(0)) { this->THPLimit = record.getItem("THP").get(0); - this->addInjectionControl(WellInjector::THP); + this->addInjectionControl(InjectorCMode::THP); } else - this->dropInjectionControl(WellInjector::THP); + this->dropInjectionControl(InjectorCMode::THP); this->VFPTableNumber = record.getItem("VFP_TABLE").get< int >(0); @@ -86,15 +86,15 @@ namespace Opm { */ this->setBHPLimit(record.getItem("BHP").get(0).get()); // BHP control should always be there. - this->addInjectionControl(WellInjector::BHP); + this->addInjectionControl(InjectorCMode::BHP); if (availableForGroupControl) - this->addInjectionControl(WellInjector::GRUP); + this->addInjectionControl(InjectorCMode::GRUP); else - this->dropInjectionControl(WellInjector::GRUP); + this->dropInjectionControl(InjectorCMode::GRUP); { const std::string& cmodeString = record.getItem("CMODE").getTrimmedString(0); - WellInjector::ControlModeEnum controlModeArg = WellInjector::ControlModeFromString( cmodeString ); + InjectorCMode controlModeArg = InjectorCModeFromString( cmodeString ); if (this->hasInjectionControl( controlModeArg)) this->controlMode = controlModeArg; else { @@ -163,20 +163,20 @@ namespace Opm { this->THPH = record.getItem("THP").getSIDouble(0); const std::string& cmodeString = record.getItem("CMODE").getTrimmedString(0); - const WellInjector::ControlModeEnum newControlMode = WellInjector::ControlModeFromString( cmodeString ); + const InjectorCMode newControlMode = InjectorCModeFromString( cmodeString ); - if ( !(newControlMode == WellInjector::RATE || newControlMode == WellInjector::BHP) ) { + if ( !(newControlMode == InjectorCMode::RATE || newControlMode == InjectorCMode::BHP) ) { const std::string msg = "Only RATE and BHP control are allowed for WCONINJH for well " + well_name; throw std::invalid_argument(msg); } // when well is under BHP control, we use its historical BHP value as BHP limit - if (newControlMode == WellInjector::BHP) { + if (newControlMode == InjectorCMode::BHP) { this->setBHPLimit(this->BHPH); } else { const bool switching_from_producer = is_producer; const bool switching_from_prediction = this->predictionMode; - const bool switching_from_BHP_control = (this->controlMode == WellInjector::BHP); + const bool switching_from_BHP_control = (this->controlMode == InjectorCMode::BHP); if (switching_from_prediction || switching_from_BHP_control || switching_from_producer) { @@ -185,7 +185,7 @@ namespace Opm { // otherwise, we keep its previous BHP limit } - this->addInjectionControl(WellInjector::BHP); + this->addInjectionControl(InjectorCMode::BHP); this->addInjectionControl(newControlMode); this->controlMode = newControlMode; this->predictionMode = false; @@ -243,7 +243,7 @@ namespace Opm { << "prediction mode: " << wp.predictionMode << ", " << "injection ctrl: " << wp.injectionControls << ", " << "injector type: " << Well2::InjectorType2String(wp.injectorType) << ", " - << "control mode: " << wp.controlMode << " }"; + << "control mode: " << Well2::InjectorCMode2String(wp.controlMode) << " }"; } diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index dbc075629..dddf05010 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -1455,13 +1455,13 @@ BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { BOOST_CHECK_EQUAL(sched.getWell2("I", 1).getInjectionProperties().BHPLimit.get(), 600 * 1e5); // 1 BOOST_CHECK_EQUAL(sched.getWell2("I", 2).getInjectionProperties().BHPLimit.get(), 600 * 1e5); // 2 - BOOST_CHECK_EQUAL(sched.getWell2("I", 2).getInjectionProperties().hasInjectionControl(Opm::WellInjector::BHP), true); + BOOST_CHECK_EQUAL(sched.getWell2("I", 2).getInjectionProperties().hasInjectionControl(Opm::Well2::InjectorCMode::BHP), true); // The well is producer for timestep 3 and the injection properties BHPLimit should be set to zero. BOOST_CHECK(sched.getWell2("I", 3).isProducer()); BOOST_CHECK_EQUAL(sched.getWell2("I", 3).getInjectionProperties().BHPLimit.get(), 0); // 3 BOOST_CHECK_EQUAL(sched.getWell2("I", 3).getProductionProperties().hasProductionControl(Opm::WellProducer::BHP), true ); - BOOST_CHECK_EQUAL(sched.getWell2("I", 4).getInjectionProperties().hasInjectionControl(Opm::WellInjector::BHP), true ); + BOOST_CHECK_EQUAL(sched.getWell2("I", 4).getInjectionProperties().hasInjectionControl(Opm::Well2::InjectorCMode::BHP), true ); BOOST_CHECK_EQUAL(sched.getWell2("I", 4).getInjectionProperties().BHPLimit.get(), 6891.2 * 1e5); // 4 } @@ -2551,37 +2551,37 @@ BOOST_AUTO_TEST_CASE(TestInjectorEnumLoop) { /*****************************************************************/ BOOST_AUTO_TEST_CASE(InjectorCOntrolMopdeEnum2String) { - BOOST_CHECK_EQUAL( "RATE" , WellInjector::ControlMode2String(WellInjector::RATE)); - BOOST_CHECK_EQUAL( "RESV" , WellInjector::ControlMode2String(WellInjector::RESV)); - BOOST_CHECK_EQUAL( "BHP" , WellInjector::ControlMode2String(WellInjector::BHP)); - BOOST_CHECK_EQUAL( "THP" , WellInjector::ControlMode2String(WellInjector::THP)); - BOOST_CHECK_EQUAL( "GRUP" , WellInjector::ControlMode2String(WellInjector::GRUP)); + BOOST_CHECK_EQUAL( "RATE" , Well2::InjectorCMode2String(Well2::InjectorCMode::RATE)); + BOOST_CHECK_EQUAL( "RESV" , Well2::InjectorCMode2String(Well2::InjectorCMode::RESV)); + BOOST_CHECK_EQUAL( "BHP" , Well2::InjectorCMode2String(Well2::InjectorCMode::BHP)); + BOOST_CHECK_EQUAL( "THP" , Well2::InjectorCMode2String(Well2::InjectorCMode::THP)); + BOOST_CHECK_EQUAL( "GRUP" , Well2::InjectorCMode2String(Well2::InjectorCMode::GRUP)); } BOOST_AUTO_TEST_CASE(InjectorControlModeEnumFromString) { - BOOST_CHECK_THROW( WellInjector::ControlModeFromString("XXX") , std::invalid_argument ); - BOOST_CHECK_EQUAL( WellInjector::RATE , WellInjector::ControlModeFromString("RATE")); - BOOST_CHECK_EQUAL( WellInjector::BHP , WellInjector::ControlModeFromString("BHP")); - BOOST_CHECK_EQUAL( WellInjector::RESV , WellInjector::ControlModeFromString("RESV")); - BOOST_CHECK_EQUAL( WellInjector::THP , WellInjector::ControlModeFromString("THP")); - BOOST_CHECK_EQUAL( WellInjector::GRUP , WellInjector::ControlModeFromString("GRUP")); + BOOST_CHECK_THROW( Well2::InjectorCModeFromString("XXX") , std::invalid_argument ); + BOOST_CHECK( Well2::InjectorCMode::RATE == Well2::InjectorCModeFromString("RATE")); + BOOST_CHECK( Well2::InjectorCMode::BHP == Well2::InjectorCModeFromString("BHP")); + BOOST_CHECK( Well2::InjectorCMode::RESV == Well2::InjectorCModeFromString("RESV")); + BOOST_CHECK( Well2::InjectorCMode::THP == Well2::InjectorCModeFromString("THP")); + BOOST_CHECK( Well2::InjectorCMode::GRUP == Well2::InjectorCModeFromString("GRUP")); } BOOST_AUTO_TEST_CASE(InjectorControlModeEnumLoop) { - BOOST_CHECK_EQUAL( WellInjector::RATE , WellInjector::ControlModeFromString( WellInjector::ControlMode2String( WellInjector::RATE ) )); - BOOST_CHECK_EQUAL( WellInjector::BHP , WellInjector::ControlModeFromString( WellInjector::ControlMode2String( WellInjector::BHP ) )); - BOOST_CHECK_EQUAL( WellInjector::RESV , WellInjector::ControlModeFromString( WellInjector::ControlMode2String( WellInjector::RESV ) )); - BOOST_CHECK_EQUAL( WellInjector::THP , WellInjector::ControlModeFromString( WellInjector::ControlMode2String( WellInjector::THP ) )); - BOOST_CHECK_EQUAL( WellInjector::GRUP , WellInjector::ControlModeFromString( WellInjector::ControlMode2String( WellInjector::GRUP ) )); + BOOST_CHECK( Well2::InjectorCMode::RATE == Well2::InjectorCModeFromString( Well2::InjectorCMode2String( Well2::InjectorCMode::RATE ) )); + BOOST_CHECK( Well2::InjectorCMode::BHP == Well2::InjectorCModeFromString( Well2::InjectorCMode2String( Well2::InjectorCMode::BHP ) )); + BOOST_CHECK( Well2::InjectorCMode::RESV == Well2::InjectorCModeFromString( Well2::InjectorCMode2String( Well2::InjectorCMode::RESV ) )); + BOOST_CHECK( Well2::InjectorCMode::THP == Well2::InjectorCModeFromString( Well2::InjectorCMode2String( Well2::InjectorCMode::THP ) )); + BOOST_CHECK( Well2::InjectorCMode::GRUP == Well2::InjectorCModeFromString( Well2::InjectorCMode2String( Well2::InjectorCMode::GRUP ) )); - BOOST_CHECK_EQUAL( "THP" , WellInjector::ControlMode2String(WellInjector::ControlModeFromString( "THP" ) )); - BOOST_CHECK_EQUAL( "RATE" , WellInjector::ControlMode2String(WellInjector::ControlModeFromString( "RATE" ) )); - BOOST_CHECK_EQUAL( "RESV" , WellInjector::ControlMode2String(WellInjector::ControlModeFromString( "RESV" ) )); - BOOST_CHECK_EQUAL( "BHP" , WellInjector::ControlMode2String(WellInjector::ControlModeFromString( "BHP" ) )); - BOOST_CHECK_EQUAL( "GRUP" , WellInjector::ControlMode2String(WellInjector::ControlModeFromString( "GRUP" ) )); + BOOST_CHECK_EQUAL( "THP" , Well2::InjectorCMode2String(Well2::InjectorCModeFromString( "THP" ) )); + BOOST_CHECK_EQUAL( "RATE" , Well2::InjectorCMode2String(Well2::InjectorCModeFromString( "RATE" ) )); + BOOST_CHECK_EQUAL( "RESV" , Well2::InjectorCMode2String(Well2::InjectorCModeFromString( "RESV" ) )); + BOOST_CHECK_EQUAL( "BHP" , Well2::InjectorCMode2String(Well2::InjectorCModeFromString( "BHP" ) )); + BOOST_CHECK_EQUAL( "GRUP" , Well2::InjectorCMode2String(Well2::InjectorCModeFromString( "GRUP" ) )); } diff --git a/tests/parser/WellTests.cpp b/tests/parser/WellTests.cpp index bfbec4f8e..b5b387d28 100644 --- a/tests/parser/WellTests.cpp +++ b/tests/parser/WellTests.cpp @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) { injProps->THPLimit.reset(200); well.updateInjection(injProps); BOOST_CHECK_EQUAL( 200 , well.getInjectionProperties().THPLimit.get()); - BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::THP )); + BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::THP )); } @@ -356,42 +356,42 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) { BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { Opm::Well2 well("WELL1", "GROUP", 0, 1, 23, 42, 2334.32, Opm::Phase::WATER, WellProducer::CMODE_UNDEFINED, WellCompletion::DEPTH, UnitSystem::newMETRIC(), 0); - BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RATE )); - BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV )); + BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RATE )); + BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV )); auto injProps1 = std::make_shared(well.getInjectionProperties()); injProps1->surfaceInjectionRate.reset(100); - injProps1->addInjectionControl(Opm::WellInjector::RATE); + injProps1->addInjectionControl(Opm::Well2::InjectorCMode::RATE); well.updateInjection(injProps1); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RATE )); - BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RATE )); + BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV )); auto injProps2 = std::make_shared(well.getInjectionProperties()); injProps2->reservoirInjectionRate.reset(100); - injProps2->addInjectionControl(Opm::WellInjector::RESV); + injProps2->addInjectionControl(Opm::Well2::InjectorCMode::RESV); well.updateInjection(injProps2); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV )); auto injProps3 = std::make_shared(well.getInjectionProperties()); injProps3->BHPLimit.reset(100); - injProps3->addInjectionControl(Opm::WellInjector::BHP); + injProps3->addInjectionControl(Opm::Well2::InjectorCMode::BHP); injProps3->THPLimit.reset(100); - injProps3->addInjectionControl(Opm::WellInjector::THP); + injProps3->addInjectionControl(Opm::Well2::InjectorCMode::THP); well.updateInjection(injProps3); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RATE )); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV )); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::THP )); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::BHP )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RATE )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::THP )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::BHP )); auto injProps4 = std::make_shared(well.getInjectionProperties()); - injProps4->dropInjectionControl( Opm::WellInjector::RESV ); + injProps4->dropInjectionControl( Opm::Well2::InjectorCMode::RESV ); well.updateInjection(injProps4); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RATE )); - BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::RESV )); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::THP )); - BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::WellInjector::BHP )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RATE )); + BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::RESV )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::THP )); + BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well2::InjectorCMode::BHP )); } /*********************************************************************/ @@ -751,7 +751,7 @@ BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) { const Opm::Well2::WellInjectionProperties Iproperties("W"); BOOST_CHECK_EQUAL( Pproperties.controlMode , Opm::WellProducer::CMODE_UNDEFINED ); - BOOST_CHECK_EQUAL( Iproperties.controlMode , Opm::WellInjector::CMODE_UNDEFINED ); + BOOST_CHECK( Iproperties.controlMode == Opm::Well2::InjectorCMode::CMODE_UNDEFINED ); } diff --git a/tests/parser/integration/ScheduleCreateFromDeck.cpp b/tests/parser/integration/ScheduleCreateFromDeck.cpp index 4c1afe32f..4a582c174 100644 --- a/tests/parser/integration/ScheduleCreateFromDeck.cpp +++ b/tests/parser/integration/ScheduleCreateFromDeck.cpp @@ -212,11 +212,11 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK_CLOSE(200000/Metric::Time , controls.reservoir_rate, 0.001); BOOST_CHECK_CLOSE(6895 * Metric::Pressure , controls.bhp_limit, 0.001); BOOST_CHECK_CLOSE(0 , controls.thp_limit , 0.001); - BOOST_CHECK_EQUAL( WellInjector::RESV , controls.cmode); - BOOST_CHECK( controls.hasControl(WellInjector::RATE )); - BOOST_CHECK( controls.hasControl(WellInjector::RESV )); - BOOST_CHECK( !controls.hasControl(WellInjector::THP)); - BOOST_CHECK( controls.hasControl(WellInjector::BHP)); + BOOST_CHECK( Well2::InjectorCMode::RESV == controls.cmode); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::RATE )); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::RESV )); + BOOST_CHECK( !controls.hasControl(Well2::InjectorCMode::THP)); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::BHP)); } @@ -227,10 +227,10 @@ BOOST_AUTO_TEST_CASE(WellTesting) { { SummaryState st; const auto controls = sched.getWell2("W_1", 12).injectionControls(st); - BOOST_CHECK( controls.hasControl(WellInjector::RATE )); - BOOST_CHECK( !controls.hasControl(WellInjector::RESV)); - BOOST_CHECK( controls.hasControl(WellInjector::THP )); - BOOST_CHECK( controls.hasControl(WellInjector::BHP )); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::RATE )); + BOOST_CHECK( !controls.hasControl(Well2::InjectorCMode::RESV)); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::THP )); + BOOST_CHECK( controls.hasControl(Well2::InjectorCMode::BHP )); } } }