opm-common
Loading...
Searching...
No Matches
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>
47class FluidStateExplicitTemperatureModule
48{
49public:
50 FluidStateExplicitTemperatureModule()
51 { Valgrind::SetUndefined(temperature_); }
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 {
87 Valgrind::CheckDefined(temperature_);
88 }
89
90protected:
91 Scalar temperature_[numPhases];
92};
93
98template <class Scalar,
99 unsigned numPhases,
100 class Implementation>
101class FluidStateEquilibriumTemperatureModule
102{
103public:
104 FluidStateEquilibriumTemperatureModule()
105 { Valgrind::SetUndefined(temperature_); }
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 {
146 Valgrind::CheckDefined(temperature_);
147 }
148
149protected:
150 Scalar temperature_;
151};
152
157template <class Scalar>
158class FluidStateNullTemperatureModule
159{
160public:
161 FluidStateNullTemperatureModule()
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.
OPM_HOST_DEVICE void SetUndefined(const T &value)
Make the memory on which an object resides undefined in valgrind runs.
Definition Valgrind.hpp:174
OPM_HOST_DEVICE bool CheckDefined(const T &value)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition Valgrind.hpp:76
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
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
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
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
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition FluidStateTemperatureModules.hpp:175
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30