Add method WellType::injection_phase()

This commit is contained in:
Joakim Hove 2020-11-04 10:37:31 +01:00
parent 46bf4e394a
commit 5738e60432
2 changed files with 23 additions and 14 deletions

View File

@ -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<class Serializer>
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;
};

View File

@ -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: