28#ifndef OPM_FLUID_STATE_FUGACITY_MODULES_HPP
29#define OPM_FLUID_STATE_FUGACITY_MODULES_HPP
43template <
class Scalar,
45 unsigned numComponents,
47class FluidStateExplicitFugacityModule
50 FluidStateExplicitFugacityModule()
59 {
return fugacityCoefficient_[phaseIdx][compIdx]; }
64 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
65 {
return asImp_().pressure(phaseIdx)*fugacityCoefficient_[phaseIdx][compIdx]*asImp_().moleFraction(phaseIdx, compIdx); }
71 { fugacityCoefficient_[phaseIdx][compIdx] = value; }
77 template <
class Flu
idState>
80 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
81 for (
unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
82 fugacityCoefficient_[phaseIdx][compIdx] = fs.fugacityCoefficient(phaseIdx, compIdx);
101 const Implementation& asImp_()
const
102 {
return *
static_cast<const Implementation*
>(
this); }
104 Scalar fugacityCoefficient_[numPhases][numComponents];
111template <
class Scalar,
113 unsigned numComponents,
114 class Implementation>
115class FluidStateImmiscibleFugacityModule
117 static_assert(numPhases == numComponents,
118 "The number of phases must be the same as the number of (pseudo-) components if you assume immiscibility");
121 FluidStateImmiscibleFugacityModule()
128 {
return (phaseIdx == compIdx)?fugacityCoefficient_[phaseIdx]:std::numeric_limits<Scalar>::infinity(); }
133 Scalar
fugacity(
unsigned phaseIdx,
unsigned compIdx)
const
134 {
return asImp_().pressure(phaseIdx)*
fugacityCoefficient(phaseIdx, compIdx)*asImp_().moleFraction(phaseIdx, compIdx); }
140 { fugacityCoefficient_[phaseIdx] = value; }
146 template <
class Flu
idState>
149 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
150 fugacityCoefficient_[phaseIdx] = fs.fugacityCoefficient(phaseIdx, phaseIdx);
168 const Implementation& asImp_()
const
169 {
return *
static_cast<const Implementation*
>(
this); }
171 Scalar fugacityCoefficient_[numPhases];
178template <
class Scalar>
179class FluidStateNullFugacityModule
182 FluidStateNullFugacityModule()
189 {
throw std::logic_error(
"Fugacity coefficients are not provided by this fluid state"); }
195 {
throw std::logic_error(
"Fugacities coefficients are not provided by this fluid state"); }
Some templates to wrap the valgrind client request macros.
OPM_HOST_DEVICE void SetUndefined(const T &value)
Make the memory on which an object resides undefined in valgrind runs.
Definition Valgrind.hpp:174
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateFugacityModules.hpp:78
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:95
void setFugacityCoefficient(unsigned phaseIdx, unsigned compIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition FluidStateFugacityModules.hpp:70
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:64
const Scalar & fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:58
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateFugacityModules.hpp:147
Scalar fugacityCoefficient(unsigned phaseIdx, unsigned compIdx) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:127
void setFugacityCoefficient(unsigned phaseIdx, const Scalar &value)
Set the fugacity of a component in a phase [].
Definition FluidStateFugacityModules.hpp:139
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:162
Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:133
const Scalar & fugacity(unsigned, unsigned) const
The fugacity of a component in a phase [Pa].
Definition FluidStateFugacityModules.hpp:194
const Scalar & fugacityCoefficient(unsigned, unsigned) const
The fugacity coefficient of a component in a phase [].
Definition FluidStateFugacityModules.hpp:188
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateFugacityModules.hpp:205
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30