version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_CVFE_ELEMENT_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_FLUXVARSCACHE_HH
14
15#include <cstddef>
16#include <vector>
17#include <utility>
18
19namespace Dumux {
20
29template<class GFVC, bool cachingEnabled>
31{};
32
37template<class GFVC>
39{
40public:
43
45 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
46
48 : gridFluxVarsCachePtr_(&global) {}
49
50 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
51 // We assume the FVGeometries to be bound at this point
52 template<class FVElementGeometry, class ElementVolumeVariables>
53 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
54 const FVElementGeometry& fvGeometry,
55 const ElementVolumeVariables& elemVolVars) &
56 { bindElement(element, fvGeometry, elemVolVars); }
57
63 template<class FVElementGeometry, class ElementVolumeVariables>
64 CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
65 const FVElementGeometry& fvGeometry,
66 const ElementVolumeVariables& elemVolVars) &&
67 {
68 this->bind(element, fvGeometry, elemVolVars);
69 return std::move(*this);
70 }
71
72 template<class FVElementGeometry, class ElementVolumeVariables>
73 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars) &
76 { eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element); }
77
83 template<class FVElementGeometry, class ElementVolumeVariables>
84 CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
85 const FVElementGeometry& fvGeometry,
86 const ElementVolumeVariables& elemVolVars) &&
87 {
88 this->bindElement(element, fvGeometry, elemVolVars);
89 return std::move(*this);
90 }
91
92 template<class FVElementGeometry, class ElementVolumeVariables>
93 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
94 const FVElementGeometry& fvGeometry,
95 const ElementVolumeVariables& elemVolVars,
96 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
97 { bindElement(element, fvGeometry, elemVolVars); }
98
104 template<class FVElementGeometry, class ElementVolumeVariables>
105 CVFEElementFluxVariablesCache 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 {
110 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
111 return std::move(*this);
112 }
113
115 template<class FVElementGeometry, class ElementVolumeVariables>
116 void update(const typename FVElementGeometry::Element& element,
117 const FVElementGeometry& fvGeometry,
118 const ElementVolumeVariables& elemVolVars) {}
119
120 // access operator
121 template<class SubControlVolumeFace>
122 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
123 { return gridFluxVarsCache().cache(eIdx_, scvf.index()); }
124
127 { return *gridFluxVarsCachePtr_; }
128
129private:
130 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
131 std::size_t eIdx_;
132};
133
138template<class GFVC>
140{
141public:
144
146 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
147
149 : gridFluxVarsCachePtr_(&global) {}
150
151 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
152 // We assume the FVGeometries to be bound at this point
153 template<class FVElementGeometry, class ElementVolumeVariables>
154 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
155 const FVElementGeometry& fvGeometry,
156 const ElementVolumeVariables& elemVolVars) &
157 {
158 bindElement(element, fvGeometry, elemVolVars);
159 }
160
166 template<class FVElementGeometry, class ElementVolumeVariables>
167 CVFEElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
168 const FVElementGeometry& fvGeometry,
169 const ElementVolumeVariables& elemVolVars) &&
170 {
171 this->bind(element, fvGeometry, elemVolVars);
172 return std::move(*this);
173 }
174
175 template<class FVElementGeometry, class ElementVolumeVariables>
176 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
177 const FVElementGeometry& fvGeometry,
178 const ElementVolumeVariables& elemVolVars) &
179 {
180 // temporary resizing of the cache
181 fluxVarsCache_.resize(fvGeometry.numScvf());
182 for (auto&& scvf : scvfs(fvGeometry))
183 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
184 }
185
191 template<class FVElementGeometry, class ElementVolumeVariables>
192 CVFEElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
193 const FVElementGeometry& fvGeometry,
194 const ElementVolumeVariables& elemVolVars) &&
195 {
196 this->bindElement(element, fvGeometry, elemVolVars);
197 return std::move(*this);
198 }
199
200 template<class FVElementGeometry, class ElementVolumeVariables>
201 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
202 const FVElementGeometry& fvGeometry,
203 const ElementVolumeVariables& elemVolVars,
204 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
205 {
206 fluxVarsCache_.resize(fvGeometry.numScvf());
207 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
208 }
209
215 template<class FVElementGeometry, class ElementVolumeVariables>
216 CVFEElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
217 const FVElementGeometry& fvGeometry,
218 const ElementVolumeVariables& elemVolVars,
219 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
220 {
221 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
222 return std::move(*this);
223 }
224
229 template<class FVElementGeometry, class ElementVolumeVariables>
230 void update(const typename FVElementGeometry::Element& element,
231 const FVElementGeometry& fvGeometry,
232 const ElementVolumeVariables& elemVolVars)
233 {
234 if constexpr (FluxVariablesCache::isSolDependent)
235 {
236 fluxVarsCache_.resize(fvGeometry.numScvf());
237 for (const auto& scvf : scvfs(fvGeometry))
238 (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf);
239 }
240 }
241
242 // access operator
243 template<class SubControlVolumeFace>
244 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
245 { return fluxVarsCache_[scvf.index()]; }
246
247 // access operator
248 template<class SubControlVolumeFace>
249 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
250 { return fluxVarsCache_[scvf.index()]; }
251
254 { return *gridFluxVarsCachePtr_; }
255
256private:
257 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
258 std::vector<FluxVariablesCache> fluxVarsCache_;
259};
260
261} // end namespace Dumux
262
263#endif
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/elementfluxvariablescache.hh:253
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:143
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:201
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:192
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:216
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:167
CVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/elementfluxvariablescache.hh:148
void update(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Update the caches if the volume variables have changed and the cache is solution-dependent.
Definition: discretization/cvfe/elementfluxvariablescache.hh:230
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:176
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:154
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:146
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/elementfluxvariablescache.hh:126
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:73
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:93
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:105
CVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/elementfluxvariablescache.hh:47
void update(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Specialization for the global caching being enabled - do nothing here.
Definition: discretization/cvfe/elementfluxvariablescache.hh:116
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:84
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:42
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:64
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/elementfluxvariablescache.hh:45
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/elementfluxvariablescache.hh:53
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:31
Definition: adapt.hh:17