27#ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
28#define OPM_GAS_PVT_MULTIPLEXER_HPP
44#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
45 switch (gasPvtApproach_) { \
46 case GasPvtApproach::DryGas: { \
47 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGas>(); \
51 case GasPvtApproach::DryHumidGas: { \
52 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGas>(); \
56 case GasPvtApproach::WetHumidGas: { \
57 auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGas>(); \
61 case GasPvtApproach::WetGas: { \
62 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGas>(); \
66 case GasPvtApproach::ThermalGas: { \
67 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGas>(); \
71 case GasPvtApproach::Co2Gas: { \
72 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2Gas>(); \
76 case GasPvtApproach::NoGas: \
77 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
80enum class GasPvtApproach {
100template <
class Scalar,
bool enableThermal = true>
106 gasPvtApproach_ = GasPvtApproach::NoGas;
107 realGasPvt_ =
nullptr;
111 : gasPvtApproach_(approach)
112 , realGasPvt_(realGasPvt)
122 switch (gasPvtApproach_) {
123 case GasPvtApproach::DryGas: {
124 delete &getRealPvt<GasPvtApproach::DryGas>();
127 case GasPvtApproach::DryHumidGas: {
128 delete &getRealPvt<GasPvtApproach::DryHumidGas>();
131 case GasPvtApproach::WetHumidGas: {
132 delete &getRealPvt<GasPvtApproach::WetHumidGas>();
135 case GasPvtApproach::WetGas: {
136 delete &getRealPvt<GasPvtApproach::WetGas>();
139 case GasPvtApproach::ThermalGas: {
140 delete &getRealPvt<GasPvtApproach::ThermalGas>();
143 case GasPvtApproach::Co2Gas: {
144 delete &getRealPvt<GasPvtApproach::Co2Gas>();
147 case GasPvtApproach::NoGas:
161 void setApproach(GasPvtApproach gasPvtAppr)
163 switch (gasPvtAppr) {
164 case GasPvtApproach::DryGas:
168 case GasPvtApproach::DryHumidGas:
172 case GasPvtApproach::WetHumidGas:
176 case GasPvtApproach::WetGas:
180 case GasPvtApproach::ThermalGas:
184 case GasPvtApproach::Co2Gas:
188 case GasPvtApproach::NoGas:
189 throw std::logic_error(
"Not implemented: Gas PVT of this deck!");
192 gasPvtApproach_ = gasPvtAppr;
196 { OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
202 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.numRegions());
return 1; }
208 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.gasReferenceDensity(regionIdx));
return 2.; }
213 template <
class Evaluation>
215 const Evaluation& temperature,
216 const Evaluation& pressure,
217 const Evaluation& Rv,
218 const Evaluation& Rvw)
const
219 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw));
return 0; }
224 template <
class Evaluation = Scalar>
226 const Evaluation& temperature,
227 const Evaluation& pressure,
228 const Evaluation& Rv,
229 const Evaluation& Rvw )
const
230 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw));
return 0; }
235 template <
class Evaluation = Scalar>
237 const Evaluation& temperature,
238 const Evaluation& pressure)
const
239 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure));
return 0; }
244 template <
class Evaluation = Scalar>
246 const Evaluation& temperature,
247 const Evaluation& pressure,
248 const Evaluation& Rv,
249 const Evaluation& Rvw)
const
250 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw));
return 0; }
255 template <
class Evaluation = Scalar>
257 const Evaluation& temperature,
258 const Evaluation& pressure)
const
259 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure));
return 0; }
264 template <
class Evaluation = Scalar>
266 const Evaluation& temperature,
267 const Evaluation& pressure)
const
268 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
273 template <
class Evaluation = Scalar>
275 const Evaluation& temperature,
276 const Evaluation& pressure,
277 const Evaluation& oilSaturation,
278 const Evaluation& maxOilSaturation)
const
279 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation));
return 0; }
284 template <
class Evaluation = Scalar>
286 const Evaluation& temperature,
287 const Evaluation& pressure)
const
288 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
293 template <
class Evaluation = Scalar>
295 const Evaluation& temperature,
296 const Evaluation& pressure,
297 const Evaluation& saltConcentration)
const
298 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration));
return 0; }
306 template <
class Evaluation = Scalar>
308 const Evaluation& temperature,
309 const Evaluation& Rv)
const
310 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv));
return 0; }
315 template <
class Evaluation>
317 const Evaluation& pressure,
318 unsigned compIdx)
const
320 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
return 0;
329 {
return gasPvtApproach_; }
332 template <GasPvtApproach approachV>
333 typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
339 template <GasPvtApproach approachV>
340 typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt()
const
343 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_);
347 template <GasPvtApproach approachV>
348 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
351 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_);
354 template <GasPvtApproach approachV>
355 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const
358 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_);
362 template <GasPvtApproach approachV>
363 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
366 return *
static_cast<WetHumidGasPvt<Scalar>*
>(realGasPvt_);
369 template <GasPvtApproach approachV>
370 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt()
const
373 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_);
377 template <GasPvtApproach approachV>
378 typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
381 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_);
384 template <GasPvtApproach approachV>
385 typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt()
const
388 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_);
392 template <GasPvtApproach approachV>
393 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
396 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_);
398 template <GasPvtApproach approachV>
399 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
402 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_);
405 template <GasPvtApproach approachV>
406 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
409 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_);
412 template <GasPvtApproach approachV>
413 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
416 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_);
419 const void* realGasPvt()
const {
return realGasPvt_; }
421 GasPvtMultiplexer<Scalar,enableThermal>& operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
423 gasPvtApproach_ = data.gasPvtApproach_;
424 switch (gasPvtApproach_) {
425 case GasPvtApproach::DryGas:
426 realGasPvt_ =
new DryGasPvt<Scalar>(*
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_));
428 case GasPvtApproach::DryHumidGas:
429 realGasPvt_ =
new DryHumidGasPvt<Scalar>(*
static_cast<const DryHumidGasPvt<Scalar>*
>(data.realGasPvt_));
431 case GasPvtApproach::WetHumidGas:
432 realGasPvt_ =
new WetHumidGasPvt<Scalar>(*
static_cast<const WetHumidGasPvt<Scalar>*
>(data.realGasPvt_));
434 case GasPvtApproach::WetGas:
435 realGasPvt_ =
new WetGasPvt<Scalar>(*
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_));
437 case GasPvtApproach::ThermalGas:
438 realGasPvt_ =
new GasPvtThermal<Scalar>(*
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_));
440 case GasPvtApproach::Co2Gas:
441 realGasPvt_ =
new Co2GasPvt<Scalar>(*
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_));
451 GasPvtApproach gasPvtApproach_;
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition: Co2GasPvt.hpp:53
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: DryGasPvt.hpp:49
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
Definition: DryHumidGasPvt.hpp:52
Definition: EclipseState.hpp:55
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:102
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition: GasPvtMultiplexer.hpp:328
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil saturated gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:256
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:201
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition: GasPvtMultiplexer.hpp:285
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtMultiplexer.hpp:245
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:214
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtMultiplexer.hpp:225
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition: GasPvtMultiplexer.hpp:316
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition: GasPvtMultiplexer.hpp:294
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of oil saturated gas.
Definition: GasPvtMultiplexer.hpp:265
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:207
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rv) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the oil compo...
Definition: GasPvtMultiplexer.hpp:307
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, const Evaluation &maxOilSaturation) const
Returns the oil vaporization factor [m^3/m^3] of oil saturated gas.
Definition: GasPvtMultiplexer.hpp:274
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:236
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:50
Definition: Schedule.hpp:130
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
Definition: WetGasPvt.hpp:51
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized oil a...
Definition: WetHumidGasPvt.hpp:51
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30