FluidStateTemperatureModules.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  Copyright (C) 2012 by Bernd Flemisch
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
27 #ifndef OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP
28 #define OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP
29 
31 
33 #include <opm/common/ErrorMacros.hpp>
34 #include <opm/common/Exceptions.hpp>
35 
36 #include <algorithm>
37 #include <cassert>
38 
39 namespace Opm {
40 
45 template <class Scalar,
46  int numPhases,
47  class Implementation>
49 {
50 public:
53 
57  Scalar temperature(unsigned phaseIdx) const
58  { return temperature_[phaseIdx]; }
59 
63  void setTemperature(unsigned phaseIdx, Scalar value)
64  { temperature_[phaseIdx] = value; }
65 
70  template <class FluidState>
71  void assign(const FluidState& fs)
72  {
73  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
74  temperature_[phaseIdx] = fs.temperature(phaseIdx);
75  }
76  }
77 
86  void checkDefined() const
87  {
89  }
90 
91 protected:
92  Scalar temperature_[numPhases];
93 };
94 
99 template <class Scalar,
100  int numPhases,
101  class Implementation>
103 {
104 public:
107 
111  Scalar temperature(unsigned /*phaseIdx*/) const
112  { return temperature_; }
113 
117  void setTemperature(Scalar value)
118  { temperature_ = value; }
119 
124  template <class FluidState>
125  void assign(const FluidState& fs)
126  {
128 
129  temperature_ = FsToolbox::template toLhs<Scalar>(fs.temperature(/*phaseIdx=*/0));
130 
131 #ifndef NDEBUG
132  typedef Opm::MathToolbox<Scalar> Toolbox;
133  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
134  assert(std::abs(FsToolbox::value(fs.temperature(phaseIdx))
135  - Toolbox::value(temperature_)) < 1e-30);
136  }
137 #endif
138  }
139 
148  void checkDefined() const
149  {
151  }
152 
153 protected:
154  Scalar temperature_;
155 };
156 
161 template <class Scalar>
163 {
164 public:
166  { }
167 
171  Scalar temperature(unsigned /* phaseIdx */) const
172  { OPM_THROW(std::runtime_error, "Temperature is not provided by this fluid state"); }
173 
178  template <class FluidState>
179  void assign(const FluidState& /* fs */)
180  { }
181 
190  void checkDefined() const
191  { }
192 };
193 
194 } // namespace Opm
195 
196 #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
Scalar temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:171
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
FluidStateExplicitTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:51
Module for the modular fluid state which stores the temperatures explicitly and assumes thermal equil...
Definition: FluidStateTemperatureModules.hpp:102
Some templates to wrap the valgrind client request macros.
FluidStateEquilibriumTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:105
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:179
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:125
Module for the modular fluid state which stores the temperatures explicitly.
Definition: FluidStateTemperatureModules.hpp:48
Scalar temperature_
Definition: FluidStateTemperatureModules.hpp:154
void setTemperature(unsigned phaseIdx, Scalar value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:63
Evaluation< Scalar, VarSetTag, numVars > abs(const Evaluation< Scalar, VarSetTag, numVars > &)
Definition: Math.hpp:41
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:148
Module for the modular fluid state which does not the temperatures but throws std::logic_error instea...
Definition: FluidStateTemperatureModules.hpp:162
FluidStateNullTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:165
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:71
Scalar temperature(unsigned phaseIdx) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:57
Scalar temperature_[numPhases]
Definition: FluidStateTemperatureModules.hpp:92
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:86
Scalar temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:111
void setTemperature(Scalar value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:117
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:190