Loading...
Searching...
No Matches
WaterPvtMultiplexer.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_WATER_PVT_MULTIPLEXER_HPP
#define OPM_WATER_PVT_MULTIPLEXER_HPP
#include <opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/BrineH2Pvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityWaterPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityBrinePvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WaterPvtThermal.hpp>
#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
switch (approach_) { \
case WaterPvtApproach::ConstantCompressibilityWater: { \
auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>(); \
codeToCall; \
__VA_ARGS__; \
} \
case WaterPvtApproach::ConstantCompressibilityBrine: { \
auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>(); \
codeToCall; \
__VA_ARGS__; \
} \
case WaterPvtApproach::ThermalWater: { \
auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWater>(); \
codeToCall; \
__VA_ARGS__; \
} \
case WaterPvtApproach::BrineCo2: { \
auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineCo2>(); \
codeToCall; \
__VA_ARGS__; \
} \
case WaterPvtApproach::BrineH2: { \
auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineH2>(); \
codeToCall; \
__VA_ARGS__; \
} \
default: \
case WaterPvtApproach::NoWater: \
throw std::logic_error("Not implemented: Water PVT of this deck!"); \
}
namespace Opm {
enum class WaterPvtApproach {
NoWater,
ConstantCompressibilityBrine,
ConstantCompressibilityWater,
ThermalWater,
BrineCo2,
BrineH2
};
#if HAVE_ECL_INPUT
class EclipseState;
class Schedule;
#endif
template <class Scalar, bool enableThermal = true, bool enableBrine = true>
class WaterPvtMultiplexer
{
public:
WaterPvtMultiplexer()
: approach_(WaterPvtApproach::NoWater)
, realWaterPvt_(nullptr)
{
}
WaterPvtMultiplexer(WaterPvtApproach approach, void* realWaterPvt)
: approach_(approach)
, realWaterPvt_(realWaterPvt)
{ }
WaterPvtMultiplexer(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
{
*this = data;
}
~WaterPvtMultiplexer();
bool mixingEnergy() const
{
return approach_ == WaterPvtApproach::ThermalWater;
}
#if HAVE_ECL_INPUT
void initFromState(const EclipseState& eclState, const Schedule& schedule);
#endif // HAVE_ECL_INPUT
void initEnd();
unsigned numRegions() const;
void setVapPars(const Scalar par1, const Scalar par2);
Scalar waterReferenceDensity(unsigned regionIdx) const;
template <class Evaluation>
Evaluation internalEnergy(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rsw,
const Evaluation& saltconcentration) const
{ OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rsw, saltconcentration)); }
Scalar hVap(unsigned regionIdx) const;
template <class Evaluation>
Evaluation viscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rsw,
const Evaluation& saltconcentration) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rsw, saltconcentration));
}
bool isActive() const
{
return approach_ != WaterPvtApproach::NoWater;
}
template <class Evaluation>
Evaluation saturatedViscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& saltconcentration) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure, saltconcentration));
}
template <class Evaluation>
Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rsw,
const Evaluation& saltconcentration) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
std::pair<LhsEval, LhsEval>
inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
{ OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
template <class Evaluation>
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& saltconcentration) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
}
template <class Evaluation>
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& saltconcentration) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, saltconcentration));
}
template <class Evaluation>
Evaluation saturationPressure(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& Rs,
const Evaluation& saltconcentration) const
{ OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs, saltconcentration)); }
template <class Evaluation>
Evaluation diffusionCoefficient(const Evaluation& temperature,
const Evaluation& pressure,
unsigned compIdx) const
{
OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
}
void setApproach(WaterPvtApproach appr);
WaterPvtApproach approach() const
{ return approach_; }
// get the concrete parameter object for the water phase
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
{
assert(approach() == approachV);
return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
{
assert(approach() == approachV);
return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
{
assert(approach() == approachV);
return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
{
assert(approach() == approachV);
return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
{
assert(approach() == approachV);
return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt() const
{
assert(approach() == approachV);
return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
{
assert(approach() == approachV);
return *static_cast<BrineCo2Pvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
{
assert(approach() == approachV);
return *static_cast<const BrineCo2Pvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
{
assert(approach() == approachV);
return *static_cast<BrineH2Pvt<Scalar>* >(realWaterPvt_);
}
template <WaterPvtApproach approachV>
typename std::enable_if<approachV == WaterPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt() const
{
assert(approach() == approachV);
return *static_cast<const BrineH2Pvt<Scalar>* >(realWaterPvt_);
}
const void* realWaterPvt() const { return realWaterPvt_; }
WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>&
operator=(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data);
private:
WaterPvtApproach approach_{WaterPvtApproach::NoWater};
void* realWaterPvt_{nullptr};
};
} // namespace Opm
#endif
BrineCo2Pvt.hpp
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
BrineH2Pvt.hpp
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a H2-Brine sy...
ConstantCompressibilityBrinePvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
ConstantCompressibilityWaterPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
WaterPvtThermal.hpp
This class implements temperature dependence of the PVT properties of water.
Opm::ConstantCompressibilityWaterPvt
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition ConstantCompressibilityWaterPvt.hpp:49
Opm::EclipseState
Definition EclipseState.hpp:62
Opm::Schedule
Definition Schedule.hpp:101
Opm::WaterPvtMultiplexer::viscosity
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:155
Opm::WaterPvtMultiplexer::saturatedInverseFormationVolumeFactor
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:206
Opm::WaterPvtMultiplexer::saturatedViscosity
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:173
Opm::WaterPvtMultiplexer::numRegions
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:97
Opm::WaterPvtMultiplexer::inverseFormationVolumeFactorAndViscosity
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:199
Opm::WaterPvtMultiplexer::saturatedGasDissolutionFactor
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the gas dissolution factor [m^3/m^3] of saturated water.
Definition WaterPvtMultiplexer.hpp:218
Opm::WaterPvtMultiplexer::internalEnergy
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition WaterPvtMultiplexer.hpp:142
Opm::WaterPvtMultiplexer::saturationPressure
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs, const Evaluation &saltconcentration) const
Returns the saturation pressure [Pa] of water given the mass fraction of the gas component in the wat...
Definition WaterPvtMultiplexer.hpp:234
Opm::WaterPvtMultiplexer::approach
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition WaterPvtMultiplexer.hpp:258
Opm::WaterPvtMultiplexer::waterReferenceDensity
Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:111
Opm::WaterPvtMultiplexer::inverseFormationVolumeFactor
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:185
Opm::WaterPvtMultiplexer::diffusionCoefficient
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 WaterPvtMultiplexer.hpp:244
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30