Merge pull request #2088 from joakim-hove/welltype-injection-phase

Add method WellType::injection_phase()
This commit is contained in:
Joakim Hove 2020-11-09 12:45:34 +01:00 committed by GitHub
commit 558cd2c1f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 14 deletions

View File

@ -58,13 +58,14 @@ public:
int ecl_phase() const; int ecl_phase() const;
Phase preferred_phase() const; Phase preferred_phase() const;
InjectorType injector_type() const; InjectorType injector_type() const;
Phase injection_phase() const;
bool operator==(const WellType& other) const; bool operator==(const WellType& other) const;
template<class Serializer> template<class Serializer>
void serializeOp(Serializer& serializer) void serializeOp(Serializer& serializer)
{ {
serializer(m_producer); serializer(m_producer);
serializer(injection_phase); serializer(m_injection_phase);
serializer(m_welspecs_phase); serializer(m_welspecs_phase);
} }
@ -83,7 +84,7 @@ private:
used when initializing the well equations for a producer. used when initializing the well equations for a producer.
*/ */
Phase injection_phase; Phase m_injection_phase;
Phase m_welspecs_phase; Phase m_welspecs_phase;
}; };

View File

@ -87,9 +87,17 @@ bool WellType::gas_injector(int ecl_wtype) {
return ecl_wtype == ecl::gas_injector; 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) : 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)) m_welspecs_phase(ecl::from_ecl_phase(ecl_phase))
{ {
this->m_producer = false; this->m_producer = false;
@ -98,13 +106,13 @@ WellType::WellType(int ecl_wtype, int ecl_phase) :
this->m_producer = true; this->m_producer = true;
break; break;
case ecl::oil_injector: case ecl::oil_injector:
this->injection_phase = Phase::OIL; this->m_injection_phase = Phase::OIL;
break; break;
case ecl::water_injector: case ecl::water_injector:
this->injection_phase = Phase::WATER; this->m_injection_phase = Phase::WATER;
break; break;
case ecl::gas_injector: case ecl::gas_injector:
this->injection_phase = Phase::GAS; this->m_injection_phase = Phase::GAS;
break; break;
default: default:
throw std::invalid_argument("Invalid integer well type ID"); 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) : WellType::WellType(bool producer, Phase phase) :
m_producer(producer), m_producer(producer),
injection_phase(phase), m_injection_phase(phase),
m_welspecs_phase(phase) m_welspecs_phase(phase)
{} {}
@ -126,7 +134,7 @@ WellType WellType::serializeObject()
{ {
WellType result; WellType result;
result.m_producer = true; result.m_producer = true;
result.injection_phase = Phase::OIL; result.m_injection_phase = Phase::OIL;
result.m_welspecs_phase = Phase::WATER; result.m_welspecs_phase = Phase::WATER;
return result; return result;
@ -148,8 +156,8 @@ bool WellType::update(InjectorType injector_type) {
} }
auto inj_phase = from_injector_type(injector_type); auto inj_phase = from_injector_type(injector_type);
if (this->injection_phase != inj_phase) { if (this->m_injection_phase != inj_phase) {
this->injection_phase = inj_phase; this->m_injection_phase = inj_phase;
ret_value = true; ret_value = true;
} }
@ -168,7 +176,7 @@ int WellType::ecl_wtype() const {
if (this->m_producer) if (this->m_producer)
return ecl::producer; return ecl::producer;
switch (this->injection_phase) { switch (this->m_injection_phase) {
case Phase::OIL: case Phase::OIL:
return ecl::oil_injector; return ecl::oil_injector;
case Phase::WATER: case Phase::WATER:
@ -201,13 +209,13 @@ int WellType::ecl_phase() const {
Phase WellType::preferred_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 { bool WellType::operator==(const WellType& other) const {
return this->m_welspecs_phase == other.m_welspecs_phase && 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; this->m_producer == other.m_producer;
} }
@ -216,7 +224,7 @@ InjectorType WellType::injector_type() const {
if (this->producer()) if (this->producer())
throw std::invalid_argument("Asked for injector type for a well which is a 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: case Phase::OIL:
return InjectorType::OIL; return InjectorType::OIL;
case Phase::WATER: case Phase::WATER: