27 #ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
28 #define OPM_GAS_PVT_MULTIPLEXER_HPP
37 #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
41 #define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
42 switch (gasPvtApproach_) { \
43 case GasPvtApproach::DryGasPvt: { \
44 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGasPvt>(); \
48 case GasPvtApproach::DryHumidGasPvt: { \
49 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGasPvt>(); \
53 case GasPvtApproach::WetGasPvt: { \
54 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGasPvt>(); \
58 case GasPvtApproach::ThermalGasPvt: { \
59 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGasPvt>(); \
63 case GasPvtApproach::Co2GasPvt: { \
64 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2GasPvt>(); \
68 case GasPvtApproach::NoGasPvt: \
69 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
72 enum class GasPvtApproach {
91 template <
class Scalar,
bool enableThermal = true>
97 gasPvtApproach_ = GasPvtApproach::NoGasPvt;
98 realGasPvt_ =
nullptr;
102 : gasPvtApproach_(approach)
103 , realGasPvt_(realGasPvt)
113 switch (gasPvtApproach_) {
114 case GasPvtApproach::DryGasPvt: {
115 delete &getRealPvt<GasPvtApproach::DryGasPvt>();
118 case GasPvtApproach::DryHumidGasPvt: {
119 delete &getRealPvt<GasPvtApproach::DryHumidGasPvt>();
122 case GasPvtApproach::WetGasPvt: {
123 delete &getRealPvt<GasPvtApproach::WetGasPvt>();
126 case GasPvtApproach::ThermalGasPvt: {
127 delete &getRealPvt<GasPvtApproach::ThermalGasPvt>();
130 case GasPvtApproach::Co2GasPvt: {
131 delete &getRealPvt<GasPvtApproach::Co2GasPvt>();
134 case GasPvtApproach::NoGasPvt:
145 void initFromState(
const EclipseState& eclState,
const Schedule& schedule)
147 if (!eclState.runspec().phases().active(Phase::GAS))
149 if (eclState.runspec().co2Storage())
150 setApproach(GasPvtApproach::Co2GasPvt);
151 else if (enableThermal && eclState.getSimulationConfig().isThermal())
152 setApproach(GasPvtApproach::ThermalGasPvt);
153 else if (!eclState.getTableManager().getPvtgTables().empty())
154 setApproach(GasPvtApproach::WetGasPvt);
155 else if (eclState.getTableManager().hasTables(
"PVDG"))
156 setApproach(GasPvtApproach::DryGasPvt);
157 else if (!eclState.getTableManager().getPvtgwTables().empty())
158 setApproach(GasPvtApproach::DryHumidGasPvt);
160 OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
164 void setApproach(GasPvtApproach gasPvtAppr)
166 switch (gasPvtAppr) {
167 case GasPvtApproach::DryGasPvt:
171 case GasPvtApproach::DryHumidGasPvt:
175 case GasPvtApproach::WetGasPvt:
179 case GasPvtApproach::ThermalGasPvt:
183 case GasPvtApproach::Co2GasPvt:
187 case GasPvtApproach::NoGasPvt:
188 throw std::logic_error(
"Not implemented: Gas PVT of this deck!");
191 gasPvtApproach_ = gasPvtAppr;
195 { OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
201 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.numRegions());
return 1; }
207 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.gasReferenceDensity(regionIdx));
return 2.; }
212 template <
class Evaluation>
214 const Evaluation& temperature,
215 const Evaluation& pressure,
216 const Evaluation& Rv)
const
217 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv));
return 0; }
222 template <
class Evaluation = Scalar>
224 const Evaluation& temperature,
225 const Evaluation& pressure,
226 const Evaluation& Rv)
const
227 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv));
return 0; }
232 template <
class Evaluation = Scalar>
234 const Evaluation& temperature,
235 const Evaluation& pressure)
const
236 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure));
return 0; }
241 template <
class Evaluation = Scalar>
243 const Evaluation& temperature,
244 const Evaluation& pressure,
245 const Evaluation& Rv)
const
246 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv));
return 0; }
251 template <
class Evaluation = Scalar>
253 const Evaluation& temperature,
254 const Evaluation& pressure)
const
255 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure));
return 0; }
260 template <
class Evaluation = Scalar>
262 const Evaluation& temperature,
263 const Evaluation& pressure)
const
264 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
269 template <
class Evaluation = Scalar>
271 const Evaluation& temperature,
272 const Evaluation& pressure,
273 const Evaluation& oilSaturation,
274 const Evaluation& maxOilSaturation)
const
275 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation));
return 0; }
280 template <
class Evaluation = Scalar>
282 const Evaluation& temperature,
283 const Evaluation& pressure)
const
284 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
292 template <
class Evaluation = Scalar>
294 const Evaluation& temperature,
295 const Evaluation& Rv)
const
296 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv));
return 0; }
301 template <
class Evaluation>
303 const Evaluation& pressure,
304 unsigned compIdx)
const
306 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
return 0;
315 {
return gasPvtApproach_; }
318 template <GasPvtApproach approachV>
319 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, DryGasPvt<Scalar> >::type& getRealPvt()
325 template <GasPvtApproach approachV>
326 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, const DryGasPvt<Scalar> >::type& getRealPvt()
const
329 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_);
333 template <GasPvtApproach approachV>
334 typename std::enable_if<approachV == GasPvtApproach::DryHumidGasPvt, DryHumidGasPvt<Scalar> >::type& getRealPvt()
337 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_);
340 template <GasPvtApproach approachV>
341 typename std::enable_if<approachV == GasPvtApproach::DryHumidGasPvt, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const
344 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_);
348 template <GasPvtApproach approachV>
349 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, WetGasPvt<Scalar> >::type& getRealPvt()
352 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_);
355 template <GasPvtApproach approachV>
356 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, const WetGasPvt<Scalar> >::type& getRealPvt()
const
359 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_);
363 template <GasPvtApproach approachV>
364 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, GasPvtThermal<Scalar> >::type& getRealPvt()
367 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_);
369 template <GasPvtApproach approachV>
370 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
373 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_);
376 template <GasPvtApproach approachV>
377 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, Co2GasPvt<Scalar> >::type& getRealPvt()
380 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_);
383 template <GasPvtApproach approachV>
384 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
387 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_);
390 const void* realGasPvt()
const {
return realGasPvt_; }
392 bool operator==(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
const
397 switch (gasPvtApproach_) {
398 case GasPvtApproach::DryGasPvt:
399 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_) ==
400 *
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_);
401 case GasPvtApproach::DryHumidGasPvt:
402 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_) ==
403 *
static_cast<const DryHumidGasPvt<Scalar>*
>(data.realGasPvt_);
404 case GasPvtApproach::WetGasPvt:
405 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_) ==
406 *
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_);
407 case GasPvtApproach::ThermalGasPvt:
408 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_) ==
409 *
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_);
410 case GasPvtApproach::Co2GasPvt:
411 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_) ==
412 *
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_);
418 GasPvtMultiplexer<Scalar,enableThermal>& operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
420 gasPvtApproach_ = data.gasPvtApproach_;
421 switch (gasPvtApproach_) {
422 case GasPvtApproach::DryGasPvt:
423 realGasPvt_ =
new DryGasPvt<Scalar>(*
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_));
425 case GasPvtApproach::DryHumidGasPvt:
426 realGasPvt_ =
new DryHumidGasPvt<Scalar>(*
static_cast<const DryHumidGasPvt<Scalar>*
>(data.realGasPvt_));
428 case GasPvtApproach::WetGasPvt:
429 realGasPvt_ =
new WetGasPvt<Scalar>(*
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_));
431 case GasPvtApproach::ThermalGasPvt:
432 realGasPvt_ =
new GasPvtThermal<Scalar>(*
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_));
434 case GasPvtApproach::Co2GasPvt:
435 realGasPvt_ =
new Co2GasPvt<Scalar>(*
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_));
445 GasPvtApproach gasPvtApproach_;
449 #undef OPM_GAS_PVT_MULTIPLEXER_CALL
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
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 with vaporized water...
This class implements temperature dependence of the PVT properties of gas.
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
Definition: Co2GasPvt.hpp:54
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: DryGasPvt.hpp:50
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
Definition: DryHumidGasPvt.hpp:54
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:93
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtMultiplexer.hpp:242
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition: GasPvtMultiplexer.hpp:314
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:252
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:200
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:281
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:302
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:261
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:206
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtMultiplexer.hpp:223
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:213
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:293
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:270
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:233
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:55
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
Definition: WetGasPvt.hpp:54