00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #ifndef OPM_PARAMETER_CACHE_BASE_HPP
00028 #define OPM_PARAMETER_CACHE_BASE_HPP
00029
00030 namespace Opm {
00031
00036 template <class Implementation>
00037 class ParameterCacheBase
00038 {
00039 public:
00043 enum ExceptQuantities {
00045 None = 0,
00046
00048 Temperature = 1,
00049
00051 Pressure = 2,
00052
00054 Composition = 4
00055 };
00056
00057 ParameterCacheBase()
00058 {}
00059
00064 template <class OtherCache>
00065 void assignPersistentData(const OtherCache& )
00066 {}
00067
00074 template <class FluidState>
00075 void updateAll(const FluidState& fluidState, int = None)
00076 {
00077 for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
00078 asImp_().updatePhase(fluidState, phaseIdx);
00079 }
00080
00090 template <class FluidState>
00091 void updateAllPressures(const FluidState& fluidState)
00092 { asImp_().updateAll(fluidState, Temperature | Composition); }
00093
00103 template <class FluidState>
00104 void updateAllTemperatures(const FluidState& fluidState)
00105 {
00106 for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
00107 asImp_().updatePhase(fluidState, phaseIdx);
00108 }
00109
00110
00118 template <class FluidState>
00119 void updatePhase(const FluidState& , unsigned , int = None)
00120 {}
00121
00133 template <class FluidState>
00134 void updateTemperature(const FluidState& fluidState, unsigned phaseIdx)
00135 {
00136 asImp_().updatePhase(fluidState, phaseIdx);
00137 }
00138
00150 template <class FluidState>
00151 void updatePressure(const FluidState& fluidState, unsigned phaseIdx)
00152 {
00153 asImp_().updatePhase(fluidState, phaseIdx);
00154 }
00155
00167 template <class FluidState>
00168 void updateComposition(const FluidState& fluidState, unsigned phaseIdx)
00169 {
00170 asImp_().updatePhase(fluidState, phaseIdx, Temperature | Pressure);
00171 }
00172
00186 template <class FluidState>
00187 void updateSingleMoleFraction(const FluidState& fluidState,
00188 unsigned phaseIdx,
00189 unsigned )
00190 {
00191 asImp_().updateComposition(fluidState, phaseIdx);
00192 }
00193
00194 private:
00195 Implementation& asImp_()
00196 { return *static_cast<Implementation*>(this); }
00197 };
00198
00199 }
00200
00201 #endif