From 5738e604321e1d78e9f98d601b1c04f5e1abd4d1 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Nov 2020 10:37:31 +0100 Subject: [PATCH] Add method WellType::injection_phase() --- .../EclipseState/Schedule/ScheduleTypes.hpp | 5 +-- .../EclipseState/Schedule/ScheduleTypes.cpp | 32 ++++++++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp b/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp index a75dd2c02..468e5f043 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp @@ -58,13 +58,14 @@ public: int ecl_phase() const; Phase preferred_phase() const; InjectorType injector_type() const; + Phase injection_phase() const; bool operator==(const WellType& other) const; template void serializeOp(Serializer& serializer) { serializer(m_producer); - serializer(injection_phase); + serializer(m_injection_phase); serializer(m_welspecs_phase); } @@ -83,7 +84,7 @@ private: used when initializing the well equations for a producer. */ - Phase injection_phase; + Phase m_injection_phase; Phase m_welspecs_phase; }; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.cpp index d1b0dc99b..12f27631d 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.cpp @@ -87,9 +87,17 @@ bool WellType::gas_injector(int ecl_wtype) { return ecl_wtype == ecl::gas_injector; } +Phase WellType::injection_phase() const { + if (this->m_producer) + throw std::logic_error("Asked for injection phase in a producer"); + + return this->m_injection_phase; +} + + WellType::WellType(int ecl_wtype, int ecl_phase) : - injection_phase(ecl::from_ecl_phase(ecl_phase)), + m_injection_phase(ecl::from_ecl_phase(ecl_phase)), m_welspecs_phase(ecl::from_ecl_phase(ecl_phase)) { this->m_producer = false; @@ -98,13 +106,13 @@ WellType::WellType(int ecl_wtype, int ecl_phase) : this->m_producer = true; break; case ecl::oil_injector: - this->injection_phase = Phase::OIL; + this->m_injection_phase = Phase::OIL; break; case ecl::water_injector: - this->injection_phase = Phase::WATER; + this->m_injection_phase = Phase::WATER; break; case ecl::gas_injector: - this->injection_phase = Phase::GAS; + this->m_injection_phase = Phase::GAS; break; default: throw std::invalid_argument("Invalid integer well type ID"); @@ -114,7 +122,7 @@ WellType::WellType(int ecl_wtype, int ecl_phase) : WellType::WellType(bool producer, Phase phase) : m_producer(producer), - injection_phase(phase), + m_injection_phase(phase), m_welspecs_phase(phase) {} @@ -126,7 +134,7 @@ WellType WellType::serializeObject() { WellType result; result.m_producer = true; - result.injection_phase = Phase::OIL; + result.m_injection_phase = Phase::OIL; result.m_welspecs_phase = Phase::WATER; return result; @@ -148,8 +156,8 @@ bool WellType::update(InjectorType injector_type) { } auto inj_phase = from_injector_type(injector_type); - if (this->injection_phase != inj_phase) { - this->injection_phase = inj_phase; + if (this->m_injection_phase != inj_phase) { + this->m_injection_phase = inj_phase; ret_value = true; } @@ -168,7 +176,7 @@ int WellType::ecl_wtype() const { if (this->m_producer) return ecl::producer; - switch (this->injection_phase) { + switch (this->m_injection_phase) { case Phase::OIL: return ecl::oil_injector; case Phase::WATER: @@ -201,13 +209,13 @@ int WellType::ecl_phase() const { Phase WellType::preferred_phase() const { - return this->injector() ? this->injection_phase : this->m_welspecs_phase; + return this->injector() ? this->m_injection_phase : this->m_welspecs_phase; } bool WellType::operator==(const WellType& other) const { return this->m_welspecs_phase == other.m_welspecs_phase && - this->injection_phase == other.injection_phase && + this->m_injection_phase == other.m_injection_phase && this->m_producer == other.m_producer; } @@ -216,7 +224,7 @@ InjectorType WellType::injector_type() const { if (this->producer()) throw std::invalid_argument("Asked for injector type for a well which is a producer"); - switch (this->injection_phase) { + switch (this->m_injection_phase) { case Phase::OIL: return InjectorType::OIL; case Phase::WATER: