My Project
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 <stdexcept>
31 
32 #include "NullParameterCache.hpp"
33 
34 #include <dune/common/classname.hh>
35 
36 namespace Opm {
37 
42 template <class ScalarT, class Implementation>
44 {
45 public:
49  typedef ScalarT Scalar;
50 
58  template <class Evaluation>
59  struct ParameterCache {
60  ParameterCache() = delete; // derived fluid systems must specify this class!
61  };
62 
64  static const int numComponents = -1000;
65 
67  static const int numPhases = -2000;
68 
74  static char* phaseName(unsigned /*phaseIdx*/)
75  {
76  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a phaseName() method!");
77  }
78 
84  static bool isLiquid(unsigned /*phaseIdx*/)
85  {
86  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a isLiquid() method!");
87  }
88 
103  static bool isIdealMixture(unsigned /*phaseIdx*/)
104  {
105  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a isIdealMixture() method!");
106  }
107 
117  static bool isCompressible(unsigned /*phaseIdx*/)
118  {
119  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a isCompressible() method!");
120  }
121 
128  static bool isIdealGas(unsigned /*phaseIdx*/)
129  {
130  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a isIdealGas() method!");
131  }
132 
138  static const char* componentName(unsigned /*compIdx*/)
139  {
140  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a componentName() method!");
141  }
142 
148  static Scalar molarMass(unsigned /*compIdx*/)
149  {
150  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a molarMass() method!");
151  }
152 
156  static void init()
157  { }
158 
165  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
166  static LhsEval density(const FluidState& /*fluidState*/,
167  const ParamCache& /*paramCache*/,
168  unsigned /*phaseIdx*/)
169  {
170  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a density() method!");
171  }
172 
187  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
188  static LhsEval fugacityCoefficient(const FluidState& /*fluidState*/,
189  ParamCache& /*paramCache*/,
190  unsigned /*phaseIdx*/,
191  unsigned /*compIdx*/)
192  {
193  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a fugacityCoefficient() method!");
194  }
195 
202  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
203  static LhsEval viscosity(const FluidState& /*fluidState*/,
204  ParamCache& /*paramCache*/,
205  unsigned /*phaseIdx*/)
206  {
207  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a viscosity() method!");
208  }
209 
227  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
228  static LhsEval diffusionCoefficient(const FluidState& /*fluidState*/,
229  ParamCache& /*paramCache*/,
230  unsigned /*phaseIdx*/,
231  unsigned /*compIdx*/)
232  {
233  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a diffusionCoefficient() method!");
234  }
235 
243  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
244  static LhsEval enthalpy(const FluidState& /*fluidState*/,
245  ParamCache& /*paramCache*/,
246  unsigned /*phaseIdx*/)
247  {
248  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide an enthalpy() method!");
249  }
250 
257  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
258  static LhsEval thermalConductivity(const FluidState& /*fluidState*/,
259  ParamCache& /*paramCache*/,
260  unsigned /*phaseIdx*/)
261  {
262  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a thermalConductivity() method!");
263  }
264 
271  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCache>
272  static LhsEval heatCapacity(const FluidState& /*fluidState*/,
273  ParamCache& /*paramCache*/,
274  unsigned /*phaseIdx*/)
275  {
276  throw std::runtime_error("Not implemented: The fluid system '"+Dune::className<Implementation>()+"' does not provide a heatCapacity() method!");
277  }
278 
279 
281  static unsigned phaseIsActive(unsigned /*phaseIdx*/)
282  {
283  return true;
284  }
285 };
286 
287 } // namespace Opm
288 
289 #endif
A parameter cache which does nothing.
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:44
static LhsEval heatCapacity(const FluidState &, ParamCache &, unsigned)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition: BaseFluidSystem.hpp:272
static unsigned phaseIsActive(unsigned)
Returns whether a fluid phase is active.
Definition: BaseFluidSystem.hpp:281
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:244
static const int numPhases
Number of fluid phases in the fluid system.
Definition: BaseFluidSystem.hpp:67
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: BaseFluidSystem.hpp:128
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: BaseFluidSystem.hpp:117
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition: BaseFluidSystem.hpp:148
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: BaseFluidSystem.hpp:103
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:228
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition: BaseFluidSystem.hpp:84
static void init()
Initialize the fluid system's static parameters.
Definition: BaseFluidSystem.hpp:156
ScalarT Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:49
static const int numComponents
Number of chemical species in the fluid system.
Definition: BaseFluidSystem.hpp:64
static LhsEval density(const FluidState &, const ParamCache &, unsigned)
Calculate the density [kg/m^3] of a fluid phase.
Definition: BaseFluidSystem.hpp:166
static const char * componentName(unsigned)
Return the human readable name of a component.
Definition: BaseFluidSystem.hpp:138
static char * phaseName(unsigned)
Return the human readable name of a fluid phase.
Definition: BaseFluidSystem.hpp:74
static LhsEval fugacityCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition: BaseFluidSystem.hpp:188
static LhsEval viscosity(const FluidState &, ParamCache &, unsigned)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition: BaseFluidSystem.hpp:203
static LhsEval thermalConductivity(const FluidState &, ParamCache &, unsigned)
Thermal conductivity of a fluid phase [W/(m K)].
Definition: BaseFluidSystem.hpp:258
The type of the fluid system's parameter cache.
Definition: BaseFluidSystem.hpp:59