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>
110class GasPvtMultiplexer
114 : gasPvtApproach_(GasPvtApproach::NoGas)
115 , realGasPvt_(
nullptr, [](
void*){})
119 GasPvtMultiplexer(GasPvtApproach
approach,
void* realGasPvt)
121 , realGasPvt_(realGasPvt, [
this](
void* ptr){ deleter(ptr); })
124 GasPvtMultiplexer(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
129 ~GasPvtMultiplexer() =
default;
131 bool mixingEnergy()
const
133 return gasPvtApproach_ == GasPvtApproach::ThermalGas;
136 bool isActive()
const {
137 return gasPvtApproach_ != GasPvtApproach::NoGas;
149 void setApproach(GasPvtApproach gasPvtAppr);
158 void setVapPars(
const Scalar par1,
const Scalar par2);
168 template <
class Evaluation>
170 const Evaluation& temperature,
171 const Evaluation& pressure,
172 const Evaluation& Rv,
173 const Evaluation& Rvw)
const
174 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw)); }
176 Scalar hVap(
unsigned regionIdx)
const;
181 template <
class Evaluation = Scalar>
183 const Evaluation& temperature,
184 const Evaluation& pressure,
185 const Evaluation& Rv,
186 const Evaluation& Rvw )
const
187 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw)); }
192 template <
class Evaluation = Scalar>
194 const Evaluation& temperature,
195 const Evaluation& pressure)
const
196 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
201 template <
class Evaluation = Scalar>
203 const Evaluation& temperature,
204 const Evaluation& pressure,
205 const Evaluation& Rv,
206 const Evaluation& Rvw)
const
207 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw)); }
212 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar>
213 std::pair<LhsEval, LhsEval>
215 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
220 template <
class Evaluation = Scalar>
222 const Evaluation& temperature,
223 const Evaluation& pressure)
const
224 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
229 template <
class Evaluation = Scalar>
231 const Evaluation& temperature,
232 const Evaluation& pressure)
const
233 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure)); }
238 template <
class Evaluation = Scalar>
240 const Evaluation& temperature,
241 const Evaluation& pressure,
242 const Evaluation& oilSaturation,
243 const Evaluation& maxOilSaturation)
const
244 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
249 template <
class Evaluation = Scalar>
251 const Evaluation& temperature,
252 const Evaluation& pressure)
const
253 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure)); }
258 template <
class Evaluation = Scalar>
260 const Evaluation& temperature,
261 const Evaluation& pressure,
262 const Evaluation& saltConcentration)
const
263 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration)); }
273 template <
class Evaluation = Scalar>
275 const Evaluation& temperature,
276 const Evaluation& Rv)
const
277 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); }
282 template <
class Evaluation>
284 const Evaluation& pressure,
285 unsigned compIdx)
const
287 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
296 {
return gasPvtApproach_; }
299 template <GasPvtApproach approachV>
300 typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
306 template <GasPvtApproach approachV>
307 typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt()
const
310 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_.get());
314 template <GasPvtApproach approachV>
315 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
318 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
321 template <GasPvtApproach approachV>
322 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const
325 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
329 template <GasPvtApproach approachV>
330 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
333 return *
static_cast<WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
336 template <GasPvtApproach approachV>
337 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt()
const
340 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
344 template <GasPvtApproach approachV>
345 typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
348 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_.get());
351 template <GasPvtApproach approachV>
352 typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt()
const
355 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_.get());
359 template <GasPvtApproach approachV>
360 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
363 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_.get());
365 template <GasPvtApproach approachV>
366 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
369 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_.get());
372 template <GasPvtApproach approachV>
373 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
376 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_.get());
379 template <GasPvtApproach approachV>
380 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
383 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_.get());
386 template <GasPvtApproach approachV>
387 typename std::enable_if<approachV == GasPvtApproach::H2Gas, H2GasPvt<Scalar> >::type& getRealPvt()
390 return *
static_cast<H2GasPvt<Scalar>*
>(realGasPvt_.get());
393 template <GasPvtApproach approachV>
394 typename std::enable_if<approachV == GasPvtApproach::H2Gas, const H2GasPvt<Scalar> >::type& getRealPvt()
const
397 return *
static_cast<const H2GasPvt<Scalar>*
>(realGasPvt_.get());
400 const void* realGasPvt()
const {
return realGasPvt_.get(); }
402 GasPvtMultiplexer<Scalar,enableThermal>&
403 operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data);
406 using UniqueVoidPtrWithDeleter = std::unique_ptr<void, std::function<void(
void*)>>;
408 template <
class ConcreteGasPvt> UniqueVoidPtrWithDeleter makeGasPvt();
410 template <
class ConcretePvt> UniqueVoidPtrWithDeleter copyPvt(
const UniqueVoidPtrWithDeleter&);
412 GasPvtApproach gasPvtApproach_{GasPvtApproach::NoGas};
413 UniqueVoidPtrWithDeleter realGasPvt_;
415 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:62
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition GasPvtMultiplexer.hpp:214
Scalar gasReferenceDensity(unsigned regionIdx) const
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:221
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:250
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:202
GasPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition GasPvtMultiplexer.hpp:295
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:169
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:182
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:283
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:259
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:230
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:274
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:239
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:193
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30