ParameterCacheBase.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*/
27#ifndef OPM_PARAMETER_CACHE_BASE_HPP
28#define OPM_PARAMETER_CACHE_BASE_HPP
29
30namespace Opm {
31
36template <class Implementation>
38{
39public:
45 None = 0,
46
49
52
54 Composition = 4
55 };
56
58 {}
59
64 template <class OtherCache>
65 void assignPersistentData(const OtherCache& /* other */)
66 {}
67
74 template <class FluidState>
75 void updateAll(const FluidState& fluidState, int /*exceptQuantities*/ = None)
76 {
77 for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
78 asImp_().updatePhase(fluidState, phaseIdx);
79 }
80
90 template <class FluidState>
91 void updateAllPressures(const FluidState& fluidState)
92 { asImp_().updateAll(fluidState, Temperature | Composition); }
93
103 template <class FluidState>
104 void updateAllTemperatures(const FluidState& fluidState)
105 {
106 for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
107 asImp_().updatePhase(fluidState, phaseIdx);
108 }
109
110
118 template <class FluidState>
119 void updatePhase(const FluidState& /*fluidState*/, unsigned /*phaseIdx*/, int /*exceptQuantities*/ = None)
120 {}
121
133 template <class FluidState>
134 void updateTemperature(const FluidState& fluidState, unsigned phaseIdx)
135 {
136 asImp_().updatePhase(fluidState, phaseIdx);
137 }
138
150 template <class FluidState>
151 void updatePressure(const FluidState& fluidState, unsigned phaseIdx)
152 {
153 asImp_().updatePhase(fluidState, phaseIdx);
154 }
155
167 template <class FluidState>
168 void updateComposition(const FluidState& fluidState, unsigned phaseIdx)
169 {
170 asImp_().updatePhase(fluidState, phaseIdx, /*except=*/Temperature | Pressure);
171 }
172
186 template <class FluidState>
187 void updateSingleMoleFraction(const FluidState& fluidState,
188 unsigned phaseIdx,
189 unsigned /*compIdx*/)
190 {
191 asImp_().updateComposition(fluidState, phaseIdx);
192 }
193
194private:
195 Implementation& asImp_()
196 { return *static_cast<Implementation*>(this); }
197};
198
199} // namespace Opm
200
201#endif
The base class of the parameter caches of fluid systems.
Definition: ParameterCacheBase.hpp:38
void updateTemperature(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on temperature.
Definition: ParameterCacheBase.hpp:134
void assignPersistentData(const OtherCache &)
Copy the data which is not dependent on the type of the Scalars from another parameter cache.
Definition: ParameterCacheBase.hpp:65
void updateAllPressures(const FluidState &fluidState)
Update pressure dependent quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:91
ParameterCacheBase()
Definition: ParameterCacheBase.hpp:57
void updateAllTemperatures(const FluidState &fluidState)
Update temperature dependent quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:104
void updateAll(const FluidState &fluidState, int=None)
Update the quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:75
void updateSingleMoleFraction(const FluidState &fluidState, unsigned phaseIdx, unsigned)
Update all cached parameters of a specific fluid phase which depend on the mole fraction of a single ...
Definition: ParameterCacheBase.hpp:187
void updateComposition(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on composition.
Definition: ParameterCacheBase.hpp:168
void updatePressure(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on pressure.
Definition: ParameterCacheBase.hpp:151
ExceptQuantities
Constants for ORing the quantities of the fluid state that have not changed since the last update.
Definition: ParameterCacheBase.hpp:43
@ Temperature
The temperature has not been modified.
Definition: ParameterCacheBase.hpp:48
@ None
All quantities have been (potentially) modified.
Definition: ParameterCacheBase.hpp:45
@ Pressure
The pressures have not been modified.
Definition: ParameterCacheBase.hpp:51
@ Composition
The compositions have not been modified.
Definition: ParameterCacheBase.hpp:54
void updatePhase(const FluidState &, unsigned, int=None)
Update all cached parameters of a specific fluid phase.
Definition: ParameterCacheBase.hpp:119
Definition: Air_Mesitylene.hpp:34