27#ifndef OPM_OIL_PVT_MULTIPLEXER_HPP
28#define OPM_OIL_PVT_MULTIPLEXER_HPP
43#define OPM_OIL_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
44 switch (approach_) { \
45 case OilPvtApproach::ConstantCompressibilityOil: { \
46 auto& pvtImpl = getRealPvt<OilPvtApproach::ConstantCompressibilityOil>(); \
50 case OilPvtApproach::DeadOil: { \
51 auto& pvtImpl = getRealPvt<OilPvtApproach::DeadOil>(); \
55 case OilPvtApproach::LiveOil: { \
56 auto& pvtImpl = getRealPvt<OilPvtApproach::LiveOil>(); \
60 case OilPvtApproach::ThermalOil: { \
61 auto& pvtImpl = getRealPvt<OilPvtApproach::ThermalOil>(); \
65 case OilPvtApproach::BrineCo2: { \
66 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineCo2>(); \
70 case OilPvtApproach::BrineH2: { \
71 auto& pvtImpl = getRealPvt<OilPvtApproach::BrineH2>(); \
75 case OilPvtApproach::ConstantRsDeadOil: { \
76 auto& pvtImpl = getRealPvt<OilPvtApproach::ConstantRsDeadOil>(); \
81 case OilPvtApproach::NoOil: \
82 throw std::logic_error("Not implemented: Oil PVT of this deck!"); \
85enum class OilPvtApproach {
89 ConstantCompressibilityOil,
108template <
class Scalar,
bool enableThermal = true>
109class OilPvtMultiplexer
113 : approach_(OilPvtApproach::NoOil)
114 , realOilPvt_(
nullptr)
118 OilPvtMultiplexer(OilPvtApproach
approach,
void* realOilPvt)
120 , realOilPvt_(realOilPvt)
123 OilPvtMultiplexer(
const OilPvtMultiplexer<Scalar,enableThermal>& data)
128 ~OilPvtMultiplexer();
130 bool mixingEnergy()
const
132 return approach_ == OilPvtApproach::ThermalOil;
144 bool isActive()
const
146 return approach_ != OilPvtApproach::NoOil;
154 void setVapPars(
const Scalar par1,
const Scalar par2);
164 template <
class Evaluation>
166 const Evaluation& temperature,
167 const Evaluation& pressure,
168 const Evaluation& Rs)
const
169 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rs)); }
171 Scalar hVap(
unsigned regionIdx)
const
172 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.hVap(regionIdx)); }
176 template <
class Evaluation>
178 const Evaluation& temperature,
179 const Evaluation& pressure,
180 const Evaluation& Rs)
const
181 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rs)); }
186 template <
class Evaluation>
188 const Evaluation& temperature,
189 const Evaluation& pressure)
const
190 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
195 template <
class Evaluation>
197 const Evaluation& temperature,
198 const Evaluation& pressure,
199 const Evaluation& Rs)
const
200 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rs)); }
205 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
206 std::pair<LhsEval, LhsEval>
208 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
213 template <
class Evaluation>
215 const Evaluation& temperature,
216 const Evaluation& pressure)
const
217 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
222 template <
class Evaluation>
224 const Evaluation& temperature,
225 const Evaluation& pressure)
const
226 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure)); }
231 template <
class Evaluation>
233 const Evaluation& temperature,
234 const Evaluation& pressure,
235 const Evaluation& oilSaturation,
236 const Evaluation& maxOilSaturation)
const
237 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
246 template <
class Evaluation>
248 const Evaluation& temperature,
249 const Evaluation& Rs)
const
250 { OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rs)); }
255 template <
class Evaluation>
257 const Evaluation& pressure,
258 unsigned compIdx)
const
260 OPM_OIL_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
263 void setApproach(OilPvtApproach appr);
271 {
return approach_; }
274 template <OilPvtApproach approachV>
275 typename std::enable_if<approachV == OilPvtApproach::LiveOil, LiveOilPvt<Scalar> >::type& getRealPvt()
281 template <OilPvtApproach approachV>
282 typename std::enable_if<approachV == OilPvtApproach::LiveOil, const LiveOilPvt<Scalar> >::type& getRealPvt()
const
285 return *
static_cast<LiveOilPvt<Scalar>*
>(realOilPvt_);
288 template <OilPvtApproach approachV>
289 typename std::enable_if<approachV == OilPvtApproach::DeadOil, DeadOilPvt<Scalar> >::type& getRealPvt()
292 return *
static_cast<DeadOilPvt<Scalar>*
>(realOilPvt_);
295 template <OilPvtApproach approachV>
296 typename std::enable_if<approachV == OilPvtApproach::DeadOil, const DeadOilPvt<Scalar> >::type& getRealPvt()
const
299 return *
static_cast<DeadOilPvt<Scalar>*
>(realOilPvt_);
302 template <OilPvtApproach approachV>
303 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
306 return *
static_cast<ConstantCompressibilityOilPvt<Scalar>*
>(realOilPvt_);
309 template <OilPvtApproach approachV>
310 typename std::enable_if<approachV == OilPvtApproach::ConstantCompressibilityOil, const ConstantCompressibilityOilPvt<Scalar> >::type& getRealPvt()
const
313 return *
static_cast<ConstantCompressibilityOilPvt<Scalar>*
>(realOilPvt_);
316 template <OilPvtApproach approachV>
317 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, OilPvtThermal<Scalar> >::type& getRealPvt()
320 return *
static_cast<OilPvtThermal<Scalar>*
>(realOilPvt_);
323 template <OilPvtApproach approachV>
324 typename std::enable_if<approachV == OilPvtApproach::ThermalOil, const OilPvtThermal<Scalar> >::type& getRealPvt()
const
327 return *
static_cast<const OilPvtThermal<Scalar>*
>(realOilPvt_);
330 template <OilPvtApproach approachV>
331 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
334 return *
static_cast<BrineCo2Pvt<Scalar>*
>(realOilPvt_);
337 template <OilPvtApproach approachV>
338 typename std::enable_if<approachV == OilPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt()
const
341 return *
static_cast<const BrineCo2Pvt<Scalar>*
>(realOilPvt_);
344 const void* realOilPvt()
const {
return realOilPvt_; }
346 template <OilPvtApproach approachV>
347 typename std::enable_if<approachV == OilPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
350 return *
static_cast<BrineH2Pvt<Scalar>*
>(realOilPvt_);
353 template <OilPvtApproach approachV>
354 typename std::enable_if<approachV == OilPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt()
const
357 return *
static_cast<const BrineH2Pvt<Scalar>*
>(realOilPvt_);
360 template <OilPvtApproach approachV>
361 typename std::enable_if<approachV == OilPvtApproach::ConstantRsDeadOil, ConstantRsDeadOilPvt<Scalar> >::type& getRealPvt()
364 return *
static_cast<ConstantRsDeadOilPvt<Scalar>*
>(realOilPvt_);
367 template <OilPvtApproach approachV>
368 typename std::enable_if<approachV == OilPvtApproach::ConstantRsDeadOil, const ConstantRsDeadOilPvt<Scalar> >::type& getRealPvt()
const
371 return *
static_cast<const ConstantRsDeadOilPvt<Scalar>*
>(realOilPvt_);
374 OilPvtMultiplexer<Scalar,enableThermal>&
375 operator=(
const OilPvtMultiplexer<Scalar,enableThermal>& data);
378 OilPvtApproach approach_{OilPvtApproach::NoOil};
379 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 dead oil with constant dissolved g...
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:66
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
Definition LiveOilPvt.hpp:49
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:116
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:165
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:196
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:187
OilPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition OilPvtMultiplexer.hpp:270
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:214
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:223
void initFromState(const EclipseState &eclState, const Schedule &schedule)
Initialize the parameters for water using an ECL state.
Definition OilPvtMultiplexer.cpp:74
Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:130
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:177
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:247
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:232
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:207
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:256
Definition Schedule.hpp:101
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30