28 #ifndef OPM_FLUID_STATE_DENSITY_MODULES_HPP
29 #define OPM_FLUID_STATE_DENSITY_MODULES_HPP
31 #include <opm/common/ErrorMacros.hpp>
32 #include <opm/common/Exceptions.hpp>
35 #include <opm/common/Valgrind.hpp>
45 template <
class Scalar,
52 { Valgrind::SetUndefined(density_); }
57 const Scalar&
density(
unsigned phaseIdx)
const
58 {
return density_[phaseIdx]; }
64 {
return density_[phaseIdx]/asImp_().averageMolarMass(phaseIdx); }
76 { density_[phaseIdx] = value; }
82 template <
class Flu
idState>
85 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
86 density_[phaseIdx] = Opm::decay<Scalar>(fs.density(phaseIdx));
100 Valgrind::CheckDefined(density_);
104 const Implementation& asImp_()
const
105 {
return *
static_cast<const Implementation*
>(
this); }
107 Scalar density_[numPhases];
114 template <
class Scalar,
116 class Implementation>
127 { OPM_THROW(std::logic_error,
"Density is not provided by this fluid state"); }
133 { OPM_THROW(std::logic_error,
"Molar density is not provided by this fluid state"); }
139 { OPM_THROW(std::logic_error,
"Molar volume is not provided by this fluid state"); }
145 template <
class Flu
idState>
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateDensityModules.hpp:83
const Scalar & molarVolume(unsigned) const
The molar volume of a fluid phase [m^3/mol].
Definition: FluidStateDensityModules.hpp:138
Scalar molarVolume(unsigned phaseIdx) const
The molar volume of a fluid phase [m^3/mol].
Definition: FluidStateDensityModules.hpp:69
const Scalar & density(unsigned) const
The density of a fluid phase [kg/m^3].
Definition: FluidStateDensityModules.hpp:126
Scalar molarDensity(unsigned phaseIdx) const
The molar density of a fluid phase [mol/m^3].
Definition: FluidStateDensityModules.hpp:63
const Scalar & molarDensity(unsigned) const
The molar density of a fluid phase [mol/m^3].
Definition: FluidStateDensityModules.hpp:132
Module for the modular fluid state which stores the densities explicitly.
Definition: FluidStateDensityModules.hpp:48
void setDensity(unsigned phaseIdx, const Scalar &value)
Set the density of a phase [kg/m^3].
Definition: FluidStateDensityModules.hpp:75
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateDensityModules.hpp:98
const Scalar & density(unsigned phaseIdx) const
The density of a fluid phase [kg/m^3].
Definition: FluidStateDensityModules.hpp:57
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateDensityModules.hpp:146
Module for the modular fluid state which does not the densities but throws std::logic_error instead...
Definition: FluidStateDensityModules.hpp:117
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateDensityModules.hpp:157