opm-common
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 <array>
36 #include <cassert>
37 
38 namespace Opm {
39 
44 template <class ValueType,
45  unsigned numPhases,
46  class Implementation>
48 {
49 public:
51  { Valgrind::SetUndefined(temperature_); }
52 
56  const ValueType& temperature(unsigned phaseIdx) const
57  { return temperature_[phaseIdx]; }
58 
62  void setTemperature(unsigned phaseIdx, const ValueType& 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 
90 protected:
91  std::array<ValueType, numPhases> temperature_{};
92 };
93 
98 template <class ValueT,
99  unsigned numPhases,
100  class Implementation>
102 {
103 public:
105  { Valgrind::SetUndefined(temperature_); }
106 
110  const ValueT& temperature(unsigned /*phaseIdx*/) const
111  { return temperature_; }
112 
116  void setTemperature(const ValueT& value)
117  { temperature_ = value; }
118 
123  template <class FluidState>
124  void assign(const FluidState& fs)
125  {
126  temperature_ = decay<ValueT>(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 
149 protected:
150  ValueT temperature_;
151 };
152 
157 template <class ValueT>
159 {
160 public:
162  { }
163 
167  const ValueT& 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
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:85
Module for the modular fluid state which stores the temperatures explicitly and assumes thermal equil...
Definition: FluidStateTemperatureModules.hpp:101
void setTemperature(unsigned phaseIdx, const ValueType &value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:62
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:70
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Module for the modular fluid state which does not the temperatures but throws std::logic_error instea...
Definition: FluidStateTemperatureModules.hpp:158
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:144
const ValueT & temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:110
void assign(const FluidState &)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:175
Module for the modular fluid state which stores the temperatures explicitly.
Definition: FluidStateTemperatureModules.hpp:47
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
void checkDefined() const
Make sure that all attributes are defined.
Definition: FluidStateTemperatureModules.hpp:186
const ValueT & temperature(unsigned) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:167
const ValueType & temperature(unsigned phaseIdx) const
The temperature of a fluid phase [-].
Definition: FluidStateTemperatureModules.hpp:56
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: FluidStateTemperatureModules.hpp:124
void setTemperature(const ValueT &value)
Set the temperature of a phase [-].
Definition: FluidStateTemperatureModules.hpp:116
Some templates to wrap the valgrind client request macros.