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_ENTHALPY_MODULES_HPP
00029 #define OPM_FLUID_STATE_ENTHALPY_MODULES_HPP
00030
00031 #include <opm/common/ErrorMacros.hpp>
00032 #include <opm/common/Exceptions.hpp>
00033
00034 #include <opm/material/common/MathToolbox.hpp>
00035 #include <opm/common/Valgrind.hpp>
00036
00037 #include <algorithm>
00038
00039 namespace Opm {
00044 template <class Scalar,
00045 unsigned numPhases,
00046 class Implementation>
00047 class FluidStateExplicitEnthalpyModule
00048 {
00049 public:
00050 FluidStateExplicitEnthalpyModule()
00051 { Valgrind::SetUndefined(enthalpy_); }
00052
00056 const Scalar& enthalpy(unsigned phaseIdx) const
00057 { return enthalpy_[phaseIdx]; }
00058
00062 Scalar internalEnergy(unsigned phaseIdx) const
00063 { return enthalpy_[phaseIdx] - asImp_().pressure(phaseIdx)/asImp_().density(phaseIdx); }
00064
00068 void setEnthalpy(unsigned phaseIdx, const Scalar& value)
00069 { enthalpy_[phaseIdx] = value; }
00070
00075 template <class FluidState>
00076 void assign(const FluidState& fs)
00077 {
00078 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
00079 enthalpy_[phaseIdx] = Opm::decay<Scalar>(fs.enthalpy(phaseIdx));
00080 }
00081 }
00082
00091 void checkDefined() const
00092 {
00093 Valgrind::CheckDefined(enthalpy_);
00094 }
00095
00096 protected:
00097 const Implementation& asImp_() const
00098 { return *static_cast<const Implementation*>(this); }
00099
00100 Scalar enthalpy_[numPhases];
00101 };
00102
00108 template <class Scalar,
00109 unsigned numPhases,
00110 class Implementation>
00111 class FluidStateNullEnthalpyModule
00112 {
00113 public:
00114 FluidStateNullEnthalpyModule()
00115 { }
00116
00120 const Scalar& internalEnergy(unsigned ) const
00121 {
00122 static Scalar tmp = 0;
00123 Valgrind::SetUndefined(tmp);
00124 return tmp;
00125 }
00126
00130 const Scalar& enthalpy(unsigned ) const
00131 {
00132 static Scalar tmp = 0;
00133 Valgrind::SetUndefined(tmp);
00134 return tmp;
00135 }
00136
00141 template <class FluidState>
00142 void assign(const FluidState& )
00143 { }
00144
00153 void checkDefined() const
00154 { }
00155 };
00156
00157 }
00158
00159 #endif