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  Copyright (C) 2011-2013 by Andreas Lauser
5  Copyright (C) 2012 by Bernd Flemisch
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
26 #ifndef OPM_PARAMETER_CACHE_BASE_HPP
27 #define OPM_PARAMETER_CACHE_BASE_HPP
28 
29 namespace Opm {
30 
35 template <class Implementation>
37 {
38 public:
44  None = 0,
45 
48 
50  Pressure = 2,
51 
54  };
55 
57  {}
58 
65  template <class FluidState>
66  void updateAll(const FluidState &fluidState, int /*exceptQuantities*/ = None)
67  {
68  for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
69  asImp_().updatePhase(fluidState, phaseIdx);
70  }
71 
81  template <class FluidState>
82  void updateAllPressures(const FluidState &fluidState)
83  { asImp_().updateAll(fluidState, Temperature | Composition); }
84 
94  template <class FluidState>
95  void updateAllTemperatures(const FluidState &fluidState)
96  {
97  for (unsigned phaseIdx = 0; phaseIdx < FluidState::numPhases; ++phaseIdx)
98  asImp_().updatePhase(fluidState, phaseIdx);
99  }
100 
101 
109  template <class FluidState>
110  void updatePhase(const FluidState& /*fluidState*/, unsigned /*phaseIdx*/, int /*exceptQuantities*/ = None)
111  {}
112 
124  template <class FluidState>
125  void updateTemperature(const FluidState &fluidState, unsigned phaseIdx)
126  {
127  asImp_().updatePhase(fluidState, phaseIdx);
128  }
129 
141  template <class FluidState>
142  void updatePressure(const FluidState &fluidState, unsigned phaseIdx)
143  {
144  asImp_().updatePhase(fluidState, phaseIdx);
145  }
146 
158  template <class FluidState>
159  void updateComposition(const FluidState &fluidState, unsigned phaseIdx)
160  {
161  asImp_().updatePhase(fluidState, phaseIdx, /*except=*/Temperature | Pressure);
162  }
163 
177  template <class FluidState>
178  void updateSingleMoleFraction(const FluidState &fluidState,
179  unsigned phaseIdx,
180  unsigned /*compIdx*/)
181  {
182  asImp_().updateComposition(fluidState, phaseIdx);
183  }
184 
185 private:
186  Implementation &asImp_()
187  { return *static_cast<Implementation*>(this); }
188 };
189 
190 } // namespace Opm
191 
192 #endif
void updateComposition(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on composition.
Definition: ParameterCacheBase.hpp:159
Definition: Air_Mesitylene.hpp:31
The compositions have not been modified.
Definition: ParameterCacheBase.hpp:53
void updateAllPressures(const FluidState &fluidState)
Update pressure dependent quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:82
void updateAllTemperatures(const FluidState &fluidState)
Update temperature dependent quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:95
All quantities have been (potentially) modified.
Definition: ParameterCacheBase.hpp:44
ExceptQuantities
Constants for ORing the quantities of the fluid state that have not changed since the last update...
Definition: ParameterCacheBase.hpp:42
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:178
The temperature has not been modified.
Definition: ParameterCacheBase.hpp:47
ParameterCacheBase()
Definition: ParameterCacheBase.hpp:56
void updatePhase(const FluidState &, unsigned, int=None)
Update all cached parameters of a specific fluid phase.
Definition: ParameterCacheBase.hpp:110
The pressures have not been modified.
Definition: ParameterCacheBase.hpp:50
The base class of the parameter caches of fluid systems.
Definition: ParameterCacheBase.hpp:36
void updateTemperature(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on temperature.
Definition: ParameterCacheBase.hpp:125
void updatePressure(const FluidState &fluidState, unsigned phaseIdx)
Update all cached parameters of a specific fluid phase which depend on pressure.
Definition: ParameterCacheBase.hpp:142
void updateAll(const FluidState &fluidState, int=None)
Update the quantities of the parameter cache for all phases.
Definition: ParameterCacheBase.hpp:66