FluidStateEnthalpyModules.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  Copyright (C) 2011-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef OPM_FLUID_STATE_ENTHALPY_MODULES_HPP
27 #define OPM_FLUID_STATE_ENTHALPY_MODULES_HPP
28 
29 #include <opm/common/ErrorMacros.hpp>
30 #include <opm/common/Exceptions.hpp>
31 
34 
35 #include <algorithm>
36 
37 namespace Opm {
42 template <class Scalar,
43  int numPhases,
44  class Implementation>
46 {
47 public:
50 
54  const Scalar& enthalpy(unsigned phaseIdx) const
55  { return enthalpy_[phaseIdx]; }
56 
60  Scalar internalEnergy(unsigned phaseIdx) const
61  { return enthalpy_[phaseIdx] - asImp_().pressure(phaseIdx)/asImp_().density(phaseIdx); }
62 
66  void setEnthalpy(unsigned phaseIdx, const Scalar& value)
67  { enthalpy_[phaseIdx] = value; }
68 
73  template <class FluidState>
74  void assign(const FluidState& fs)
75  {
76  typedef typename FluidState::Scalar FsScalar;
77  typedef Opm::MathToolbox<FsScalar> FsToolbox;
78  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
79  enthalpy_[phaseIdx] = FsToolbox::template toLhs<Scalar>(fs.enthalpy(phaseIdx));
80  }
81  }
82 
91  void checkDefined() const
92  {
94  }
95 
96 protected:
97  const Implementation &asImp_() const
98  { return *static_cast<const Implementation*>(this); }
99 
100  Scalar enthalpy_[numPhases];
101 };
102 
108 template <class Scalar,
109  int numPhases,
110  class Implementation>
112 {
113 public:
115  { }
116 
120  const Scalar& internalEnergy(int /* phaseIdx */) const
121  {
122  static Scalar tmp = 0;
124  return tmp;
125  }
126 
130  const Scalar& enthalpy(int /* phaseIdx */) const
131  {
132  static Scalar tmp = 0;
134  return tmp;
135  }
136 
141  template <class FluidState>
142  void assign(const FluidState& /* fs */)
143  { }
144 
153  void checkDefined() const
154  { }
155 };
156 
157 } // namespace Opm
158 
159 #endif
void SetUndefined(const T &value OPM_UNUSED)
Make the memory on which an object resides undefined in valgrind runs.
Definition: Valgrind.hpp:138
bool CheckDefined(const T &value OPM_UNUSED)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateEnthalpyModules.hpp:91
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateEnthalpyModules.hpp:153
FluidStateNullEnthalpyModule()
Definition: FluidStateEnthalpyModules.hpp:114
Module for the modular fluid state which stores the enthalpies explicitly.
Definition: FluidStateEnthalpyModules.hpp:45
Some templates to wrap the valgrind client request macros.
Module for the modular fluid state which does not store the enthalpies but returns 0 instead...
Definition: FluidStateEnthalpyModules.hpp:111
const Scalar & internalEnergy(int) const
The specific internal energy of a fluid phase [J/kg].
Definition: FluidStateEnthalpyModules.hpp:120
void setEnthalpy(unsigned phaseIdx, const Scalar &value)
Set the specific enthalpy of a phase [J/kg].
Definition: FluidStateEnthalpyModules.hpp:66
const Scalar & enthalpy(int) const
The specific enthalpy of a fluid phase [J/kg].
Definition: FluidStateEnthalpyModules.hpp:130
const Implementation & asImp_() const
Definition: FluidStateEnthalpyModules.hpp:97
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateEnthalpyModules.hpp:142
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateEnthalpyModules.hpp:74
Scalar internalEnergy(unsigned phaseIdx) const
The specific internal energy of a fluid phase [J/kg].
Definition: FluidStateEnthalpyModules.hpp:60
Scalar enthalpy_[numPhases]
Definition: FluidStateEnthalpyModules.hpp:100
const Scalar & enthalpy(unsigned phaseIdx) const
The specific enthalpy of a fluid phase [J/kg].
Definition: FluidStateEnthalpyModules.hpp:54
FluidStateExplicitEnthalpyModule()
Definition: FluidStateEnthalpyModules.hpp:48
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...