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 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_TEMPERATURE_MODULES_HPP
29#define OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP
30
32
34
35#include <algorithm>
36#include <cassert>
37
38namespace Opm {
39
44template <class Scalar,
45 unsigned numPhases,
46 class Implementation>
48{
49public:
52
56 const Scalar& temperature(unsigned phaseIdx) const
57 { return temperature_[phaseIdx]; }
58
62 void setTemperature(unsigned phaseIdx, const Scalar& value)
63 { temperature_[phaseIdx] = value; }
64
69 template <class FluidState>
70 void assign(const FluidState& fs)
71 {
72 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
73 temperature_[phaseIdx] = fs.temperature(phaseIdx);
74 }
75 }
76
85 void checkDefined() const
86 {
88 }
89
90protected:
91 Scalar temperature_[numPhases];
92};
93
98template <class Scalar,
99 unsigned numPhases,
100 class Implementation>
102{
103public:
106
110 const Scalar& temperature(unsigned /*phaseIdx*/) const
111 { return temperature_; }
112
116 void setTemperature(const Scalar& value)
117 { temperature_ = value; }
118
123 template <class FluidState>
124 void assign(const FluidState& fs)
125 {
126 temperature_ = decay<Scalar>(fs.temperature(/*phaseIdx=*/0));
127
128#ifndef NDEBUG
129 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
130 assert(std::abs(scalarValue(fs.temperature(phaseIdx))
131 - scalarValue(temperature_)) < 1e-30);
132 }
133#endif
134 }
135
144 void checkDefined() const
145 {
147 }
148
149protected:
151};
152
157template <class Scalar>
159{
160public:
162 { }
163
167 const Scalar& temperature(unsigned /* phaseIdx */) const
168 { throw std::runtime_error("Temperature is not provided by this fluid state"); }
169
174 template <class FluidState>
175 void assign(const FluidState& /* fs */)
176 { }
177
186 void checkDefined() const
187 { }
188};
189
190} // namespace Opm
191
192#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 temperatures explicitly and assumes thermal equil...
Definition: FluidStateTemperatureModules.hpp:102
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:124
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:144
Scalar temperature_
Definition: FluidStateTemperatureModules.hpp:150
FluidStateEquilibriumTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:104
void setTemperature(const Scalar &value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:116
const Scalar & temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:110
Module for the modular fluid state which stores the temperatures explicitly.
Definition: FluidStateTemperatureModules.hpp:48
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:70
const Scalar & temperature(unsigned phaseIdx) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:56
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:85
void setTemperature(unsigned phaseIdx, const Scalar &value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:62
Scalar temperature_[numPhases]
Definition: FluidStateTemperatureModules.hpp:91
FluidStateExplicitTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:50
Module for the modular fluid state which does not the temperatures but throws std::logic_error instea...
Definition: FluidStateTemperatureModules.hpp:159
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:186
const Scalar & temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:167
FluidStateNullTemperatureModule()
Definition: FluidStateTemperatureModules.hpp:161
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:175
bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
void SetUndefined(const T &value)
Make the memory on which an object resides undefined in valgrind runs.
Definition: Valgrind.hpp:171
Definition: Air_Mesitylene.hpp:34
auto scalarValue(const Evaluation &val) -> decltype(MathToolbox< Evaluation >::scalarValue(val))
Definition: MathToolbox.hpp:335
Evaluation abs(const Evaluation &value)
Definition: MathToolbox.hpp:350