My Project
Loading...
Searching...
No Matches
BaseFluidSystem.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*/
27#ifndef OPM_BASE_FLUID_SYSTEM_HPP
28#define OPM_BASE_FLUID_SYSTEM_HPP
29
30#include <opm/common/utility/Demangle.hpp>
31
32#include <stdexcept>
33#include <string_view>
34
36
37#include <typeinfo>
38
39namespace Opm {
40
45template <class ScalarT, class Implementation>
47{
48public:
52 typedef ScalarT Scalar;
53
61 template <class Evaluation>
63 ParameterCache() = delete; // derived fluid systems must specify this class!
64 };
65
67 static const int numComponents = -1000;
68
70 static const int numPhases = -2000;
71
77 static std::string_view phaseName(unsigned /*phaseIdx*/)
78 {
79 throw std::runtime_error(not_implemented("phaseName"));
80 }
81
87 static bool isLiquid(unsigned /*phaseIdx*/)
88 {
89 throw std::runtime_error(not_implemented("isLiquid"));
90 }
91
106 static bool isIdealMixture(unsigned /*phaseIdx*/)
107 {
108 throw std::runtime_error(not_implemented("isIdealMixture"));
109 }
110
120 static bool isCompressible(unsigned /*phaseIdx*/)
121 {
122 throw std::runtime_error(not_implemented("isCompressible"));
123 }
124
131 static bool isIdealGas(unsigned /*phaseIdx*/)
132 {
133 throw std::runtime_error(not_implemented("isIdealGas"));
134 }
135
141 static std::string_view componentName(unsigned /*compIdx*/)
142 {
143 throw std::runtime_error(not_implemented("componentName"));
144 }
145
151 static Scalar molarMass(unsigned /*compIdx*/)
152 {
153 throw std::runtime_error(not_implemented("molarMass"));
154 }
155
161 static Scalar acentricFactor(unsigned /*compIdx*/)
162 {
163 throw std::runtime_error(not_implemented("acentricFactor"));
164 }
165
169 static void init()
170 { }
171
178 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
179 static LhsEval density(const FluidState& /*fluidState*/,
180 const ParamCache& /*paramCache*/,
181 unsigned /*phaseIdx*/)
182 {
183 throw std::runtime_error(not_implemented("density"));
184 }
185
200 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
201 static LhsEval fugacityCoefficient(const FluidState& /*fluidState*/,
202 ParamCache& /*paramCache*/,
203 unsigned /*phaseIdx*/,
204 unsigned /*compIdx*/)
205 {
206 throw std::runtime_error(not_implemented("fugacityCoefficient"));
207 }
208
215 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
216 static LhsEval viscosity(const FluidState& /*fluidState*/,
217 ParamCache& /*paramCache*/,
218 unsigned /*phaseIdx*/)
219 {
220 throw std::runtime_error(not_implemented("viscosity"));
221 }
222
240 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
241 static LhsEval diffusionCoefficient(const FluidState& /*fluidState*/,
242 ParamCache& /*paramCache*/,
243 unsigned /*phaseIdx*/,
244 unsigned /*compIdx*/)
245 {
246 throw std::runtime_error(not_implemented("diffusionCoefficient"));
247 }
248
256 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
257 static LhsEval enthalpy(const FluidState& /*fluidState*/,
258 ParamCache& /*paramCache*/,
259 unsigned /*phaseIdx*/)
260 {
261 throw std::runtime_error(not_implemented("enthalpy"));
262 }
263
270 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
271 static LhsEval thermalConductivity(const FluidState& /*fluidState*/,
272 ParamCache& /*paramCache*/,
273 unsigned /*phaseIdx*/)
274 {
275 throw std::runtime_error(not_implemented("thermalConductivity"));
276 }
277
284 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
285 static LhsEval heatCapacity(const FluidState& /*fluidState*/,
286 ParamCache& /*paramCache*/,
287 unsigned /*phaseIdx*/)
288 {
289 throw std::runtime_error(not_implemented("heatCapacity"));
290 }
291
292
294 static bool phaseIsActive(unsigned /*phaseIdx*/)
295 {
296 return true;
297 }
298
299private:
300 static std::string not_implemented(const std::string_view method)
301 {
302 return "Not implemented: The fluid system '" +
303 demangle(typeid(Implementation).name()) +
304 "' does not provide a " + method.data() + "() method!";
305 }
306};
307
308} // namespace Opm
309
310#endif
A parameter cache which does nothing.
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:47
static bool phaseIsActive(unsigned)
Returns whether a fluid phase is active.
Definition BaseFluidSystem.hpp:294
static LhsEval heatCapacity(const FluidState &, ParamCache &, unsigned)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition BaseFluidSystem.hpp:285
static std::string_view phaseName(unsigned)
Return the human readable name of a fluid phase.
Definition BaseFluidSystem.hpp:77
static LhsEval enthalpy(const FluidState &, ParamCache &, unsigned)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition BaseFluidSystem.hpp:257
static const int numPhases
Number of fluid phases in the fluid system.
Definition BaseFluidSystem.hpp:70
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition BaseFluidSystem.hpp:131
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition BaseFluidSystem.hpp:120
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition BaseFluidSystem.hpp:151
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition BaseFluidSystem.hpp:106
static LhsEval diffusionCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition BaseFluidSystem.hpp:241
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition BaseFluidSystem.hpp:87
static void init()
Initialize the fluid system's static parameters.
Definition BaseFluidSystem.hpp:169
ScalarT Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:52
static const int numComponents
Number of chemical species in the fluid system.
Definition BaseFluidSystem.hpp:67
static LhsEval density(const FluidState &, const ParamCache &, unsigned)
Calculate the density [kg/m^3] of a fluid phase.
Definition BaseFluidSystem.hpp:179
static Scalar acentricFactor(unsigned)
Return the acetntric factor of a component.
Definition BaseFluidSystem.hpp:161
static LhsEval fugacityCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition BaseFluidSystem.hpp:201
static LhsEval viscosity(const FluidState &, ParamCache &, unsigned)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition BaseFluidSystem.hpp:216
static std::string_view componentName(unsigned)
Return the human readable name of a component.
Definition BaseFluidSystem.hpp:141
static LhsEval thermalConductivity(const FluidState &, ParamCache &, unsigned)
Thermal conductivity of a fluid phase [W/(m K)].
Definition BaseFluidSystem.hpp:271
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
std::string demangle(const char *mangled_symbol)
Returns demangled name of symbol.
Definition Demangle.cpp:32
The type of the fluid system's parameter cache.
Definition BaseFluidSystem.hpp:62