3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/cvfe/elementfluxvariablescache.hh
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program 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 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_CVFE_ELEMENT_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_FLUXVARSCACHE_HH
26
27#include <cstddef>
28#include <vector>
29#include <utility>
30
31namespace Dumux {
32
41template<class GFVC, bool cachingEnabled>
43{};
44
49template<class GFVC>
51{
52public:
55
57 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
58
60 : gridFluxVarsCachePtr_(&global) {}
61
62 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
63 // We assume the FVGeometries to be bound at this point
64 template<class FVElementGeometry, class ElementVolumeVariables>
65 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
66 const FVElementGeometry& fvGeometry,
67 const ElementVolumeVariables& elemVolVars) &
68 { bindElement(element, fvGeometry, elemVolVars); }
69
75 template<class FVElementGeometry, class ElementVolumeVariables>
76 CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
77 const FVElementGeometry& fvGeometry,
78 const ElementVolumeVariables& elemVolVars) &&
79 {
80 this->bind(element, fvGeometry, elemVolVars);
81 return std::move(*this);
82 }
83
84 template<class FVElementGeometry, class ElementVolumeVariables>
85 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
86 const FVElementGeometry& fvGeometry,
87 const ElementVolumeVariables& elemVolVars) &
88 { eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element); }
89
95 template<class FVElementGeometry, class ElementVolumeVariables>
96 CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
97 const FVElementGeometry& fvGeometry,
98 const ElementVolumeVariables& elemVolVars) &&
99 {
100 this->bindElement(element, fvGeometry, elemVolVars);
101 return std::move(*this);
102 }
103
104 template<class FVElementGeometry, class ElementVolumeVariables>
105 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
106 const FVElementGeometry& fvGeometry,
107 const ElementVolumeVariables& elemVolVars,
108 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
109 { bindElement(element, fvGeometry, elemVolVars); }
110
116 template<class FVElementGeometry, class ElementVolumeVariables>
117 CVFEElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
118 const FVElementGeometry& fvGeometry,
119 const ElementVolumeVariables& elemVolVars,
120 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
121 {
122 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
123 return std::move(*this);
124 }
125
126 // access operator
127 template<class SubControlVolumeFace>
128 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
129 { return gridFluxVarsCache().cache(eIdx_, scvf.index()); }
130
133 { return *gridFluxVarsCachePtr_; }
134
135private:
136 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
137 std::size_t eIdx_;
138};
139
144template<class GFVC>
146{
147public:
150
152 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
153
155 : gridFluxVarsCachePtr_(&global) {}
156
157 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
158 // We assume the FVGeometries to be bound at this point
159 template<class FVElementGeometry, class ElementVolumeVariables>
160 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
161 const FVElementGeometry& fvGeometry,
162 const ElementVolumeVariables& elemVolVars) &
163 {
164 bindElement(element, fvGeometry, elemVolVars);
165 }
166
172 template<class FVElementGeometry, class ElementVolumeVariables>
173 CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
174 const FVElementGeometry& fvGeometry,
175 const ElementVolumeVariables& elemVolVars) &&
176 {
177 this->bind(element, fvGeometry, elemVolVars);
178 return std::move(*this);
179 }
180
181 template<class FVElementGeometry, class ElementVolumeVariables>
182 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
183 const FVElementGeometry& fvGeometry,
184 const ElementVolumeVariables& elemVolVars) &
185 {
186 // temporary resizing of the cache
187 fluxVarsCache_.resize(fvGeometry.numScvf());
188 for (auto&& scvf : scvfs(fvGeometry))
189 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
190 }
191
197 template<class FVElementGeometry, class ElementVolumeVariables>
198 CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
199 const FVElementGeometry& fvGeometry,
200 const ElementVolumeVariables& elemVolVars) &&
201 {
202 this->bindElement(element, fvGeometry, elemVolVars);
203 return std::move(*this);
204 }
205
206 template<class FVElementGeometry, class ElementVolumeVariables>
207 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
208 const FVElementGeometry& fvGeometry,
209 const ElementVolumeVariables& elemVolVars,
210 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
211 {
212 fluxVarsCache_.resize(fvGeometry.numScvf());
213 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
214 }
215
221 template<class FVElementGeometry, class ElementVolumeVariables>
222 CVFEElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
223 const FVElementGeometry& fvGeometry,
224 const ElementVolumeVariables& elemVolVars,
225 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
226 {
227 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
228 return std::move(*this);
229 }
230
231 // access operator
232 template<class SubControlVolumeFace>
233 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
234 { return fluxVarsCache_[scvf.index()]; }
235
236 // access operator
237 template<class SubControlVolumeFace>
238 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
239 { return fluxVarsCache_[scvf.index()]; }
240
243 { return *gridFluxVarsCachePtr_; }
244
245private:
246 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
247 std::vector<FluxVariablesCache> fluxVarsCache_;
248};
249
250} // end namespace Dumux
251
252#endif
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:43
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/elementfluxvariablescache.hh:132
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:85
void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:105
CVFEElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:117
CVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/elementfluxvariablescache.hh:59
CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:96
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:54
CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:76
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:57
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:65
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/elementfluxvariablescache.hh:242
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:149
void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:207
CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:198
CVFEElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:222
CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: discretization/cvfe/elementfluxvariablescache.hh:173
CVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/elementfluxvariablescache.hh:154
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:182
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:160
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:152