27 #ifndef OPM_WATER_PVT_MULTIPLEXER_HPP
28 #define OPM_WATER_PVT_MULTIPLEXER_HPP
35 #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
36 #include <opm/input/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,
157 const Evaluation& saltconcentration)
const
158 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, saltconcentration));
return 0; }
163 template <
class Evaluation>
165 const Evaluation& temperature,
166 const Evaluation& pressure,
167 const Evaluation& saltconcentration)
const
169 OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, saltconcentration));
176 template <
class Evaluation>
178 const Evaluation& temperature,
179 const Evaluation& pressure,
180 const Evaluation& saltconcentration)
const
181 { OPM_WATER_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
185 void setApproach(WaterPvtApproach appr)
188 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
192 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
196 case WaterPvtApproach::ThermalWaterPvt:
200 case WaterPvtApproach::NoWaterPvt:
201 throw std::logic_error(
"Not implemented: Water PVT of this deck!");
213 {
return approach_; }
216 template <WaterPvtApproach approachV>
217 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
223 template <WaterPvtApproach approachV>
224 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWaterPvt, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
const
227 return *
static_cast<ConstantCompressibilityWaterPvt<Scalar>*
>(realWaterPvt_);
230 template <WaterPvtApproach approachV>
231 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
234 return *
static_cast<ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_);
237 template <WaterPvtApproach approachV>
238 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrinePvt, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
const
241 return *
static_cast<ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_);
244 template <WaterPvtApproach approachV>
245 typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
248 return *
static_cast<WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_);
251 template <WaterPvtApproach approachV>
252 typename std::enable_if<approachV == WaterPvtApproach::ThermalWaterPvt, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
const
255 return *
static_cast<WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_);
258 const void* realWaterPvt()
const {
return realWaterPvt_; }
260 bool operator==(
const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
const
262 if (this->
approach() != data.approach())
266 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
267 return *
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(realWaterPvt_) ==
268 *
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(data.realWaterPvt_);
269 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
270 return *
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(realWaterPvt_) ==
271 *
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(data.realWaterPvt_);
272 case WaterPvtApproach::ThermalWaterPvt:
273 return *
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(realWaterPvt_) ==
274 *
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(data.realWaterPvt_);
280 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& operator=(
const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
282 approach_ = data.approach_;
284 case WaterPvtApproach::ConstantCompressibilityWaterPvt:
285 realWaterPvt_ =
new ConstantCompressibilityWaterPvt<Scalar>(*
static_cast<const ConstantCompressibilityWaterPvt<Scalar>*
>(data.realWaterPvt_));
287 case WaterPvtApproach::ConstantCompressibilityBrinePvt:
288 realWaterPvt_ =
new ConstantCompressibilityBrinePvt<Scalar>(*
static_cast<const ConstantCompressibilityBrinePvt<Scalar>*
>(data.realWaterPvt_));
290 case WaterPvtApproach::ThermalWaterPvt:
291 realWaterPvt_ =
new WaterPvtThermal<Scalar, enableBrine>(*
static_cast<const WaterPvtThermal<Scalar, enableBrine>*
>(data.realWaterPvt_));
301 WaterPvtApproach approach_;
305 #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:43
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:177
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:164
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition: WaterPvtMultiplexer.hpp:212
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:154
This class implements temperature dependence of the PVT properties of water.
Definition: WaterPvtThermal.hpp:50