27 #ifndef OPM_WATER_PVT_MULTIPLEXER_HPP
28 #define OPM_WATER_PVT_MULTIPLEXER_HPP
35 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
36 #include <opm/parser/eclipse/EclipseState/Runspec.hpp>
39 #define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall) \
40 switch (approach_) { \
41 case WaterPvtApproach::ConstantCompressibilityWaterPvt: { \
42 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWaterPvt>(); \
46 case WaterPvtApproach::ConstantCompressibilityBrinePvt: { \
47 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrinePvt>(); \
51 case WaterPvtApproach::ThermalWaterPvt: { \
52 auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWaterPvt>(); \
56 case WaterPvtApproach::NoWaterPvt: \
57 throw std::logic_error("Not implemented: Water PVT of this deck!"); \
62 enum class WaterPvtApproach {
64 ConstantCompressibilityBrinePvt,
65 ConstantCompressibilityWaterPvt,
73 template <
class Scalar,
bool enableThermal = true,
bool enableBrine = true>
79 approach_ = WaterPvtApproach::NoWaterPvt;
80 realWaterPvt_ =
nullptr;
85 , realWaterPvt_(realWaterPvt)
96 case WaterPvtApproach::ConstantCompressibilityWaterPvt: {
97 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityWaterPvt>();
100 case WaterPvtApproach::ConstantCompressibilityBrinePvt: {
101 delete &getRealPvt<WaterPvtApproach::ConstantCompressibilityBrinePvt>();
104 case WaterPvtApproach::ThermalWaterPvt: {
105 delete &getRealPvt<WaterPvtApproach::ThermalWaterPvt>();
108 case WaterPvtApproach::NoWaterPvt:
119 void initFromState(
const EclipseState& eclState,
const Schedule& schedule)
121 if (!eclState.runspec().phases().active(Phase::WATER))
124 if (enableThermal && eclState.getSimulationConfig().isThermal())
125 setApproach(WaterPvtApproach::ThermalWaterPvt);
126 else if (!eclState.getTableManager().getPvtwTable().empty())
127 setApproach(WaterPvtApproach::ConstantCompressibilityWaterPvt);
128 else if (enableBrine && !eclState.getTableManager().getPvtwSaltTables().empty())
129 setApproach(WaterPvtApproach::ConstantCompressibilityBrinePvt);
131 OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
136 { OPM_WATER_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
142 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.numRegions());
return 1; }
148 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.waterReferenceDensity(regionIdx));
return 1000.; }
153 template <
class Evaluation>
155 const Evaluation& temperature,
156 const Evaluation& pressure)
const
157 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure));
return 0; }
162 template <
class Evaluation>
164 const Evaluation& temperature,
165 const Evaluation& pressure,
166 const Evaluation& saltconcentration)
const
168 OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, saltconcentration));
175 template <
class Evaluation>
177 const Evaluation& temperature,
178 const Evaluation& pressure,
179 const Evaluation& saltconcentration)
const
180 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
184 void setApproach(WaterPvtApproach appr)
187 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
191 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
195 case WaterPvtApproach::ThermalWaterPvt:
199 case WaterPvtApproach::NoWaterPvt:
200 throw std::logic_error(
"Not implemented: Water PVT of this deck!");
212 {
return approach_; }
215 template <WaterPvtApproach approachV>
216 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
222 template <WaterPvtApproach approachV>
223 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
const
226 return *
static_cast<ConstantCompressibilityWaterPvt<Scalar>*
>(realWaterPvt_);
229 template <WaterPvtApproach approachV>
230 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
233 return *
static_cast<ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_);
236 template <WaterPvtApproach approachV>
237 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
const
240 return *
static_cast<ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_);
243 template <WaterPvtApproach approachV>
244 typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
247 return *
static_cast<WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_);
250 template <WaterPvtApproach approachV>
251 typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
const
254 return *
static_cast<WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_);
257 const void* realWaterPvt()
const {
return realWaterPvt_; }
259 bool operator==(
const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
const
261 if (this->
approach() != data.approach())
265 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
266 return *
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(realWaterPvt_) ==
267 *
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(data.realWaterPvt_);
268 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
269 return *
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_) ==
270 *
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(data.realWaterPvt_);
271 case WaterPvtApproach::ThermalWaterPvt:
272 return *
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_) ==
273 *
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(data.realWaterPvt_);
279 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& operator=(
const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
281 approach_ = data.approach_;
283 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
284 realWaterPvt_ =
new ConstantCompressibilityWaterPvt<Scalar>(*
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(data.realWaterPvt_));
286 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
287 realWaterPvt_ =
new ConstantCompressibilityBrinePvt<Scalar>(*
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(data.realWaterPvt_));
289 case WaterPvtApproach::ThermalWaterPvt:
290 realWaterPvt_ =
new WaterPvtThermal<Scalar, enableBrine>(*
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(data.realWaterPvt_));
300 WaterPvtApproach approach_;
304 #undef OPM_WATER_PVT_MULTIPLEXER_CALL
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class implements temperature dependence of the PVT properties of water.
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityBrinePvt.hpp:49
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: ConstantCompressibilityWaterPvt.hpp:45
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition: WaterPvtMultiplexer.hpp:75
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: WaterPvtMultiplexer.hpp:141
const Scalar waterReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: WaterPvtMultiplexer.hpp:147
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition: WaterPvtMultiplexer.hpp:176
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:163
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:154
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition: WaterPvtMultiplexer.hpp:211
This class implements temperature dependence of the PVT properties of water.
Definition: WaterPvtThermal.hpp:55