My Project
Loading...
Searching...
No Matches
FluidStateDensityModules.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
28#ifndef OPM_FLUID_STATE_DENSITY_MODULES_HPP
29#define OPM_FLUID_STATE_DENSITY_MODULES_HPP
30
33
34#include <algorithm>
35
36namespace Opm {
37
42template <class Scalar,
43 unsigned numPhases,
44 class Implementation>
46{
47public:
49 { Valgrind::SetUndefined(density_); }
50
54 const Scalar& density(unsigned phaseIdx) const
55 { return density_[phaseIdx]; }
56
60 Scalar molarDensity(unsigned phaseIdx) const
61 { return density_[phaseIdx]/asImp_().averageMolarMass(phaseIdx); }
62
66 Scalar molarVolume(unsigned phaseIdx) const
67 { return 1/molarDensity(phaseIdx); }
68
72 void setDensity(unsigned phaseIdx, const Scalar& value)
73 { density_[phaseIdx] = value; }
74
79 template <class FluidState>
80 void assign(const FluidState& fs)
81 {
82 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
83 density_[phaseIdx] = decay<Scalar>(fs.density(phaseIdx));
84 }
85 }
86
95 void checkDefined() const
96 {
97 Valgrind::CheckDefined(density_);
98 }
99
100protected:
101 const Implementation& asImp_() const
102 { return *static_cast<const Implementation*>(this); }
103
104 Scalar density_[numPhases];
105};
106
111template <class Scalar,
112 unsigned numPhases,
113 class Implementation>
115{
116public:
118 { }
119
123 const Scalar& density(unsigned /* phaseIdx */) const
124 { throw std::logic_error("Density is not provided by this fluid state"); }
125
129 const Scalar& molarDensity(unsigned /* phaseIdx */) const
130 { throw std::logic_error("Molar density is not provided by this fluid state"); }
131
135 const Scalar& molarVolume(unsigned /* phaseIdx */) const
136 { throw std::logic_error("Molar volume is not provided by this fluid state"); }
137
142 template <class FluidState>
143 void assign(const FluidState& /* fs */)
144 { }
145
154 void checkDefined() const
155 { }
156};
157
158} // namespace Opm
159
160#endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Some templates to wrap the valgrind client request macros.
Module for the modular fluid state which stores the densities explicitly.
Definition FluidStateDensityModules.hpp:46
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateDensityModules.hpp:95
Scalar molarDensity(unsigned phaseIdx) const
The molar density of a fluid phase [mol/m^3].
Definition FluidStateDensityModules.hpp:60
Scalar molarVolume(unsigned phaseIdx) const
The molar volume of a fluid phase [m^3/mol].
Definition FluidStateDensityModules.hpp:66
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateDensityModules.hpp:80
void setDensity(unsigned phaseIdx, const Scalar &value)
Set the density of a phase [kg/m^3].
Definition FluidStateDensityModules.hpp:72
const Scalar & density(unsigned phaseIdx) const
The density of a fluid phase [kg/m^3].
Definition FluidStateDensityModules.hpp:54
Module for the modular fluid state which does not the densities but throws std::logic_error instead.
Definition FluidStateDensityModules.hpp:115
const Scalar & density(unsigned) const
The density of a fluid phase [kg/m^3].
Definition FluidStateDensityModules.hpp:123
const Scalar & molarDensity(unsigned) const
The molar density of a fluid phase [mol/m^3].
Definition FluidStateDensityModules.hpp:129
const Scalar & molarVolume(unsigned) const
The molar volume of a fluid phase [m^3/mol].
Definition FluidStateDensityModules.hpp:135
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateDensityModules.hpp:143
void checkDefined() const
Make sure that all attributes are defined.
Definition FluidStateDensityModules.hpp:154
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30