27#ifndef OPM_OIL_PVT_MULTIPLEXER_HPP
28#define OPM_OIL_PVT_MULTIPLEXER_HPP
44#define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
45 switch (approach_) { \
46 case OilPvtApproach::ConstantCompressibilityOil: { \
47 auto& pvtImpl = getRealPvt<OilPvtApproach::ConstantCompressibilityOil>(); \
51 case OilPvtApproach::DeadOil: { \
52 auto& pvtImpl = getRealPvt<OilPvtApproach::DeadOil>(); \
56 case OilPvtApproach::LiveOil: { \
57 auto& pvtImpl = getRealPvt<OilPvtApproach::LiveOil>(); \
61 case OilPvtApproach::ThermalOil: { \
62 auto& pvtImpl = getRealPvt<OilPvtApproach::ThermalOil>(); \
66 case OilPvtApproach::BrineCo2: { \
67 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineCo2>(); \
71 case OilPvtApproach::BrineH2: { \
72 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineH2>(); \
77 case OilPvtApproach::NoOil: \
78 throw std::logic_error("Not implemented: Oil PVT of this deck!"); \
81enum class OilPvtApproach {
85 ConstantCompressibilityOil,
103template <
class Scalar,
bool enableThermal = true>
104class OilPvtMultiplexer
108 : approach_(OilPvtApproach::NoOil)
109 , realOilPvt_(
nullptr)
113 OilPvtMultiplexer(OilPvtApproach
approach,
void* realOilPvt)
115 , realOilPvt_(realOilPvt)
118 OilPvtMultiplexer(
const OilPvtMultiplexer<Scalar,enableThermal>& data)
123 ~OilPvtMultiplexer();
125 bool mixingEnergy()
const
127 return approach_ == OilPvtApproach::ThermalOil;
141 bool isActive()
const
143 return approach_ != OilPvtApproach::NoOil;
151 void setVapPars(
const Scalar par1,
const Scalar par2);
161 template <
class Evaluation>
163 const Evaluation& temperature,
164 const Evaluation& pressure,
165 const Evaluation& Rs)
const
166 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rs)); }
168 Scalar hVap(
unsigned regionIdx)
const
169 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.hVap(regionIdx)); }
173 template <
class Evaluation>
175 const Evaluation& temperature,
176 const Evaluation& pressure,
177 const Evaluation& Rs)
const
178 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rs)); }
183 template <
class Evaluation>
185 const Evaluation& temperature,
186 const Evaluation& pressure)
const
187 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
192 template <
class Evaluation>
194 const Evaluation& temperature,
195 const Evaluation& pressure,
196 const Evaluation& Rs)
const
197 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rs)); }
202 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar>
203 std::pair<LhsEval, LhsEval>
205 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
210 template <
class Evaluation>
212 const Evaluation& temperature,
213 const Evaluation& pressure)
const
214 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
219 template <
class Evaluation>
221 const Evaluation& temperature,
222 const Evaluation& pressure)
const
223 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure)); }
228 template <
class Evaluation>
230 const Evaluation& temperature,
231 const Evaluation& pressure,
232 const Evaluation& oilSaturation,
233 const Evaluation& maxOilSaturation)
const
234 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
243 template <
class Evaluation>
245 const Evaluation& temperature,
246 const Evaluation& Rs)
const
247 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rs)); }
252 template <
class Evaluation>
254 const Evaluation& pressure,
255 unsigned compIdx)
const
257 OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
260 void setApproach(OilPvtApproach appr);
268 {
return approach_; }
271 template <OilPvtApproach approachV>
272 typename std::enable_if<approachV == OilPvtApproach::LiveOil, LiveOilPvt<Scalar> >::type& getRealPvt()
278 template <OilPvtApproach approachV>
279 typename std::enable_if<approachV == OilPvtApproach::LiveOil, const LiveOilPvt<Scalar> >::type& getRealPvt()
const
282 return *
static_cast<LiveOilPvt<Scalar>*
>(realOilPvt_);
285 template <OilPvtApproach approachV>
286 typename std::enable_if<approachV == OilPvtApproach::DeadOil, DeadOilPvt<Scalar> >::type& getRealPvt()
289 return *
static_cast<DeadOilPvt<Scalar>*
>(realOilPvt_);
292 template <OilPvtApproach approachV>
293 typename std::enable_if<approachV == OilPvtApproach::DeadOil, const DeadOilPvt<Scalar> >::type& getRealPvt()
const
296 return *
static_cast<DeadOilPvt<Scalar>*
>(realOilPvt_);
299 template <OilPvtApproach approachV>
300 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
303 return *
static_cast<ConstantCompressibilityOilPvt<Scalar>*
>(realOilPvt_);
306 template <OilPvtApproach approachV>
307 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, const ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
const
310 return *
static_cast<ConstantCompressibilityOilPvt<Scalar>*
>(realOilPvt_);
313 template <OilPvtApproach approachV>
314 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, OilPvtThermal<Scalar> >::type& getRealPvt()
317 return *
static_cast<OilPvtThermal<Scalar>*
>(realOilPvt_);
320 template <OilPvtApproach approachV>
321 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, const OilPvtThermal<Scalar> >::type& getRealPvt()
const
324 return *
static_cast<const OilPvtThermal<Scalar>*
>(realOilPvt_);
327 template <OilPvtApproach approachV>
328 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
331 return *
static_cast<BrineCo2Pvt<Scalar>*
>(realOilPvt_);
334 template <OilPvtApproach approachV>
335 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt()
const
338 return *
static_cast<const BrineCo2Pvt<Scalar>*
>(realOilPvt_);
341 const void* realOilPvt()
const {
return realOilPvt_; }
343 template <OilPvtApproach approachV>
344 typename std::enable_if<approachV == OilPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
347 return *
static_cast<BrineH2Pvt<Scalar>*
>(realOilPvt_);
350 template <OilPvtApproach approachV>
351 typename std::enable_if<approachV == OilPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt()
const
354 return *
static_cast<const BrineH2Pvt<Scalar>*
>(realOilPvt_);
357 OilPvtMultiplexer<Scalar,enableThermal>&
358 operator=(
const OilPvtMultiplexer<Scalar,enableThermal>& data);
361 OilPvtApproach approach_{OilPvtApproach::NoOil};
362 void* realOilPvt_{
nullptr};
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a H2-Brine sy...
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
This class implements temperature dependence of the PVT properties of oil.
Definition EclipseState.hpp:62
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
Definition LiveOilPvt.hpp:51
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:102
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the specific enthalpy [J/kg] oil given a set of parameters.
Definition OilPvtMultiplexer.hpp:162
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:193
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition OilPvtMultiplexer.hpp:184
OilPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition OilPvtMultiplexer.hpp:267
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:211
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the gas dissolution factor [m^3/m^3] of saturated oil.
Definition OilPvtMultiplexer.hpp:220
Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:116
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition OilPvtMultiplexer.hpp:174
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs) const
Returns the saturation pressure [Pa] of oil given the mass fraction of the gas component in the oil p...
Definition OilPvtMultiplexer.hpp:244
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, const Evaluation &maxOilSaturation) const
Returns the gas dissolution factor [m^3/m^3] of saturated oil.
Definition OilPvtMultiplexer.hpp:229
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition OilPvtMultiplexer.hpp:204
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 OilPvtMultiplexer.hpp:253
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30