27 #ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
28 #define OPM_GAS_PVT_MULTIPLEXER_HPP
36 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
40 #define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
41 switch (gasPvtApproach_) { \
42 case GasPvtApproach::DryGasPvt: { \
43 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGasPvt>(); \
47 case GasPvtApproach::WetGasPvt: { \
48 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGasPvt>(); \
52 case GasPvtApproach::ThermalGasPvt: { \
53 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGasPvt>(); \
57 case GasPvtApproach::Co2GasPvt: { \
58 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2GasPvt>(); \
62 case GasPvtApproach::NoGasPvt: \
63 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
66 enum class GasPvtApproach {
84 template <
class Scalar,
bool enableThermal = true>
90 gasPvtApproach_ = GasPvtApproach::NoGasPvt;
91 realGasPvt_ =
nullptr;
95 : gasPvtApproach_(approach)
96 , realGasPvt_(realGasPvt)
106 switch (gasPvtApproach_) {
107 case GasPvtApproach::DryGasPvt: {
108 delete &getRealPvt<GasPvtApproach::DryGasPvt>();
111 case GasPvtApproach::WetGasPvt: {
112 delete &getRealPvt<GasPvtApproach::WetGasPvt>();
115 case GasPvtApproach::ThermalGasPvt: {
116 delete &getRealPvt<GasPvtApproach::ThermalGasPvt>();
119 case GasPvtApproach::Co2GasPvt: {
120 delete &getRealPvt<GasPvtApproach::Co2GasPvt>();
123 case GasPvtApproach::NoGasPvt:
134 void initFromState(
const EclipseState& eclState,
const Schedule& schedule)
136 if (!eclState.runspec().phases().active(Phase::GAS))
138 if (eclState.runspec().co2Storage())
139 setApproach(GasPvtApproach::Co2GasPvt);
140 else if (enableThermal && eclState.getSimulationConfig().isThermal())
141 setApproach(GasPvtApproach::ThermalGasPvt);
142 else if (!eclState.getTableManager().getPvtgTables().empty())
143 setApproach(GasPvtApproach::WetGasPvt);
144 else if (eclState.getTableManager().hasTables(
"PVDG"))
145 setApproach(GasPvtApproach::DryGasPvt);
147 OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
151 void setApproach(GasPvtApproach gasPvtAppr)
153 switch (gasPvtAppr) {
154 case GasPvtApproach::DryGasPvt:
158 case GasPvtApproach::WetGasPvt:
162 case GasPvtApproach::ThermalGasPvt:
166 case GasPvtApproach::Co2GasPvt:
170 case GasPvtApproach::NoGasPvt:
171 throw std::logic_error(
"Not implemented: Gas PVT of this deck!");
174 gasPvtApproach_ = gasPvtAppr;
178 { OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
184 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.numRegions());
return 1; }
190 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.gasReferenceDensity(regionIdx));
return 2.; }
195 template <
class Evaluation>
197 const Evaluation& temperature,
198 const Evaluation& pressure,
199 const Evaluation& Rv)
const
200 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv));
return 0; }
205 template <
class Evaluation = Scalar>
207 const Evaluation& temperature,
208 const Evaluation& pressure,
209 const Evaluation& Rv)
const
210 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv));
return 0; }
215 template <
class Evaluation = Scalar>
217 const Evaluation& temperature,
218 const Evaluation& pressure)
const
219 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure));
return 0; }
224 template <
class Evaluation = Scalar>
226 const Evaluation& temperature,
227 const Evaluation& pressure,
228 const Evaluation& Rv)
const
229 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv));
return 0; }
234 template <
class Evaluation = Scalar>
236 const Evaluation& temperature,
237 const Evaluation& pressure)
const
238 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure));
return 0; }
243 template <
class Evaluation = Scalar>
245 const Evaluation& temperature,
246 const Evaluation& pressure)
const
247 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
252 template <
class Evaluation = Scalar>
254 const Evaluation& temperature,
255 const Evaluation& pressure,
256 const Evaluation& oilSaturation,
257 const Evaluation& maxOilSaturation)
const
258 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation));
return 0; }
266 template <
class Evaluation = Scalar>
268 const Evaluation& temperature,
269 const Evaluation& Rv)
const
270 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv));
return 0; }
275 template <
class Evaluation>
277 const Evaluation& pressure,
278 unsigned compIdx)
const
280 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
return 0;
289 {
return gasPvtApproach_; }
292 template <GasPvtApproach approachV>
293 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, DryGasPvt<Scalar> >::type& getRealPvt()
299 template <GasPvtApproach approachV>
300 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, const DryGasPvt<Scalar> >::type& getRealPvt()
const
303 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_);
307 template <GasPvtApproach approachV>
308 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, WetGasPvt<Scalar> >::type& getRealPvt()
311 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_);
314 template <GasPvtApproach approachV>
315 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, const WetGasPvt<Scalar> >::type& getRealPvt()
const
318 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_);
322 template <GasPvtApproach approachV>
323 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, GasPvtThermal<Scalar> >::type& getRealPvt()
326 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_);
329 template <GasPvtApproach approachV>
330 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
333 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_);
336 template <GasPvtApproach approachV>
337 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, Co2GasPvt<Scalar> >::type& getRealPvt()
340 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_);
343 template <GasPvtApproach approachV>
344 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
347 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_);
350 const void* realGasPvt()
const {
return realGasPvt_; }
352 bool operator==(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
const
357 switch (gasPvtApproach_) {
358 case GasPvtApproach::DryGasPvt:
359 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_) ==
360 *
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_);
361 case GasPvtApproach::WetGasPvt:
362 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_) ==
363 *
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_);
364 case GasPvtApproach::ThermalGasPvt:
365 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_) ==
366 *
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_);
367 case GasPvtApproach::Co2GasPvt:
368 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_) ==
369 *
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_);
375 GasPvtMultiplexer<Scalar,enableThermal>& operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
377 gasPvtApproach_ = data.gasPvtApproach_;
378 switch (gasPvtApproach_) {
379 case GasPvtApproach::DryGasPvt:
380 realGasPvt_ =
new DryGasPvt<Scalar>(*
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_));
382 case GasPvtApproach::WetGasPvt:
383 realGasPvt_ =
new WetGasPvt<Scalar>(*
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_));
385 case GasPvtApproach::ThermalGasPvt:
386 realGasPvt_ =
new GasPvtThermal<Scalar>(*
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_));
388 case GasPvtApproach::Co2GasPvt:
389 realGasPvt_ =
new Co2GasPvt<Scalar>(*
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_));
399 GasPvtApproach gasPvtApproach_;
403 #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 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 in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:86
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:225
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition: GasPvtMultiplexer.hpp:288
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:235
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:183
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:276
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:244
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:189
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:206
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:196
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:267
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:253
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:216
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