27#ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
28#define OPM_GAS_PVT_MULTIPLEXER_HPP
46#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
47 switch (gasPvtApproach_) { \
48 case GasPvtApproach::DryGas: { \
49 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGas>(); \
53 case GasPvtApproach::DryHumidGas: { \
54 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGas>(); \
58 case GasPvtApproach::WetHumidGas: { \
59 auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGas>(); \
63 case GasPvtApproach::WetGas: { \
64 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGas>(); \
68 case GasPvtApproach::ThermalGas: { \
69 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGas>(); \
73 case GasPvtApproach::Co2Gas: { \
74 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2Gas>(); \
78 case GasPvtApproach::H2Gas: { \
79 auto& pvtImpl = getRealPvt<GasPvtApproach::H2Gas>(); \
84 case GasPvtApproach::NoGas: \
85 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
88enum class GasPvtApproach {
109template <
class Scalar,
bool enableThermal = true>
114 : gasPvtApproach_(GasPvtApproach::NoGas)
115 , realGasPvt_(
nullptr, [](
void*){})
120 : gasPvtApproach_(approach)
121 , realGasPvt_(realGasPvt, [
this](
void* ptr){ deleter(ptr); })
131 bool mixingEnergy()
const
133 return gasPvtApproach_ == GasPvtApproach::ThermalGas;
145 void setApproach(GasPvtApproach gasPvtAppr);
154 void setVapPars(
const Scalar par1,
const Scalar par2);
164 template <
class Evaluation>
166 const Evaluation& temperature,
167 const Evaluation& pressure,
168 const Evaluation& Rv,
169 const Evaluation& Rvw)
const
170 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw)); }
172 Scalar hVap(
unsigned regionIdx)
const;
177 template <
class Evaluation = Scalar>
179 const Evaluation& temperature,
180 const Evaluation& pressure,
181 const Evaluation& Rv,
182 const Evaluation& Rvw )
const
183 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw)); }
188 template <
class Evaluation = Scalar>
190 const Evaluation& temperature,
191 const Evaluation& pressure)
const
192 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
197 template <
class Evaluation = Scalar>
199 const Evaluation& temperature,
200 const Evaluation& pressure,
201 const Evaluation& Rv,
202 const Evaluation& Rvw)
const
203 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw)); }
208 template <
class Evaluation = Scalar>
210 const Evaluation& temperature,
211 const Evaluation& pressure)
const
212 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
217 template <
class Evaluation = Scalar>
219 const Evaluation& temperature,
220 const Evaluation& pressure)
const
221 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure)); }
226 template <
class Evaluation = Scalar>
228 const Evaluation& temperature,
229 const Evaluation& pressure,
230 const Evaluation& oilSaturation,
231 const Evaluation& maxOilSaturation)
const
232 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
237 template <
class Evaluation = Scalar>
239 const Evaluation& temperature,
240 const Evaluation& pressure)
const
241 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure)); }
246 template <
class Evaluation = Scalar>
248 const Evaluation& temperature,
249 const Evaluation& pressure,
250 const Evaluation& saltConcentration)
const
251 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration)); }
259 template <
class Evaluation = Scalar>
261 const Evaluation& temperature,
262 const Evaluation& Rv)
const
263 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); }
268 template <
class Evaluation>
270 const Evaluation& pressure,
271 unsigned compIdx)
const
273 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
282 {
return gasPvtApproach_; }
285 template <GasPvtApproach approachV>
286 typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
292 template <GasPvtApproach approachV>
293 typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt()
const
296 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_.get());
300 template <GasPvtApproach approachV>
301 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
304 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
307 template <GasPvtApproach approachV>
308 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const
311 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
315 template <GasPvtApproach approachV>
316 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
319 return *
static_cast<WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
322 template <GasPvtApproach approachV>
323 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt()
const
326 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
330 template <GasPvtApproach approachV>
331 typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
334 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_.get());
337 template <GasPvtApproach approachV>
338 typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt()
const
341 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_.get());
345 template <GasPvtApproach approachV>
346 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
349 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_.get());
351 template <GasPvtApproach approachV>
352 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
355 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_.get());
358 template <GasPvtApproach approachV>
359 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
362 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_.get());
365 template <GasPvtApproach approachV>
366 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
369 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_.get());
372 template <GasPvtApproach approachV>
373 typename std::enable_if<approachV == GasPvtApproach::H2Gas, H2GasPvt<Scalar> >::type& getRealPvt()
376 return *
static_cast<H2GasPvt<Scalar>*
>(realGasPvt_.get());
379 template <GasPvtApproach approachV>
380 typename std::enable_if<approachV == GasPvtApproach::H2Gas, const H2GasPvt<Scalar> >::type& getRealPvt()
const
383 return *
static_cast<const H2GasPvt<Scalar>*
>(realGasPvt_.get());
386 const void* realGasPvt()
const {
return realGasPvt_.get(); }
388 GasPvtMultiplexer<Scalar,enableThermal>&
389 operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data);
392 using UniqueVoidPtrWithDeleter = std::unique_ptr<void, std::function<void(
void*)>>;
394 template <
class ConcreteGasPvt> UniqueVoidPtrWithDeleter makeGasPvt();
396 template <
class ConcretePvt> UniqueVoidPtrWithDeleter copyPvt(
const UniqueVoidPtrWithDeleter&);
398 GasPvtApproach gasPvtApproach_{GasPvtApproach::NoGas};
399 UniqueVoidPtrWithDeleter realGasPvt_;
401 void deleter(
void* ptr);
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 phase for H2.
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 with vaporized oil a...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition DryGasPvt.hpp:50
Definition EclipseState.hpp:63
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition GasPvtMultiplexer.hpp:111
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition GasPvtMultiplexer.hpp:281
Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:57
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:209
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:41
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:238
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:198
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:165
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:178
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:269
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:247
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:218
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:260
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:227
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:189
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30