00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP
00029 #define OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP
00030
00031 #include <opm/common/Valgrind.hpp>
00032
00033 #include <opm/material/common/MathToolbox.hpp>
00034 #include <opm/common/ErrorMacros.hpp>
00035 #include <opm/common/Exceptions.hpp>
00036
00037 #include <algorithm>
00038 #include <cassert>
00039
00040 namespace Opm {
00041
00046 template <class Scalar,
00047 unsigned numPhases,
00048 class Implementation>
00049 class FluidStateExplicitTemperatureModule
00050 {
00051 public:
00052 FluidStateExplicitTemperatureModule()
00053 { Valgrind::SetUndefined(temperature_); }
00054
00058 const Scalar& temperature(unsigned phaseIdx) const
00059 { return temperature_[phaseIdx]; }
00060
00064 void setTemperature(unsigned phaseIdx, const Scalar& value)
00065 { temperature_[phaseIdx] = value; }
00066
00071 template <class FluidState>
00072 void assign(const FluidState& fs)
00073 {
00074 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
00075 temperature_[phaseIdx] = fs.temperature(phaseIdx);
00076 }
00077 }
00078
00087 void checkDefined() const
00088 {
00089 Valgrind::CheckDefined(temperature_);
00090 }
00091
00092 protected:
00093 Scalar temperature_[numPhases];
00094 };
00095
00100 template <class Scalar,
00101 unsigned numPhases,
00102 class Implementation>
00103 class FluidStateEquilibriumTemperatureModule
00104 {
00105 public:
00106 FluidStateEquilibriumTemperatureModule()
00107 { Valgrind::SetUndefined(temperature_); }
00108
00112 const Scalar& temperature(unsigned ) const
00113 { return temperature_; }
00114
00118 void setTemperature(const Scalar& value)
00119 { temperature_ = value; }
00120
00125 template <class FluidState>
00126 void assign(const FluidState& fs)
00127 {
00128 temperature_ = Opm::decay<Scalar>(fs.temperature(0));
00129
00130 #ifndef NDEBUG
00131 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
00132 assert(std::abs(Opm::scalarValue(fs.temperature(phaseIdx))
00133 - Opm::scalarValue(temperature_)) < 1e-30);
00134 }
00135 #endif
00136 }
00137
00146 void checkDefined() const
00147 {
00148 Valgrind::CheckDefined(temperature_);
00149 }
00150
00151 protected:
00152 Scalar temperature_;
00153 };
00154
00159 template <class Scalar>
00160 class FluidStateNullTemperatureModule
00161 {
00162 public:
00163 FluidStateNullTemperatureModule()
00164 { }
00165
00169 const Scalar& temperature(unsigned ) const
00170 { OPM_THROW(std::runtime_error, "Temperature is not provided by this fluid state"); }
00171
00176 template <class FluidState>
00177 void assign(const FluidState& )
00178 { }
00179
00188 void checkDefined() const
00189 { }
00190 };
00191
00192 }
00193
00194 #endif