12#ifndef DUMUX_DISCRETIZATION_HYBRID_CVFE_ELEMENT_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_HYBRID_CVFE_ELEMENT_FLUXVARSCACHE_HH
24#include <dumux/common/concepts/ipdata_.hh>
37template<
class GFVC,
bool cachingEnabled>
55 : gridFluxVarsCachePtr_(&global) {}
59 template<
class FVElementGeometry,
class ElementVolumeVariables>
60 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
61 const FVElementGeometry& fvGeometry,
62 const ElementVolumeVariables& elemVolVars) &
63 { bindElement(element, fvGeometry, elemVolVars); }
70 template<
class FVElementGeometry,
class ElementVolumeVariables>
72 const FVElementGeometry& fvGeometry,
73 const ElementVolumeVariables& elemVolVars) &&
75 this->bind(element, fvGeometry, elemVolVars);
76 return std::move(*
this);
79 template<
class FVElementGeometry,
class ElementVolumeVariables>
80 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
81 const FVElementGeometry& fvGeometry,
82 const ElementVolumeVariables& elemVolVars) &
83 { eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element); }
90 template<
class FVElementGeometry,
class ElementVolumeVariables>
92 const FVElementGeometry& fvGeometry,
93 const ElementVolumeVariables& elemVolVars) &&
95 this->bindElement(element, fvGeometry, elemVolVars);
96 return std::move(*
this);
99 template<
class FVElementGeometry,
class ElementVolumeVariables>
100 void bindScvf(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
101 const FVElementGeometry& fvGeometry,
102 const ElementVolumeVariables& elemVolVars,
103 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
104 { bindElement(element, fvGeometry, elemVolVars); }
111 template<
class FVElementGeometry,
class ElementVolumeVariables>
113 const FVElementGeometry& fvGeometry,
114 const ElementVolumeVariables& elemVolVars,
115 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
117 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
118 return std::move(*
this);
122 template<
class FVElementGeometry,
class ElementVolumeVariables>
123 void update(
const typename FVElementGeometry::Element& element,
124 const FVElementGeometry& fvGeometry,
125 const ElementVolumeVariables& elemVolVars) {}
128 template<Concept::ScvfQpIpData IpData>
131 return gridFluxVarsCache().cache(eIdx_, ipData.scvfIndex(), ipData.qpIndex());
135 template<Concept::BoundaryFaceQpIpData IpData>
138 return gridFluxVarsCache().boundaryFaceCache(eIdx_, ipData.boundaryFaceIndex(), ipData.qpIndex());
142 template<Concept::QIpData IpData>
145 return gridFluxVarsCache().elementCache(eIdx_, ipData.qpIndex());
150 {
return *gridFluxVarsCachePtr_; }
153 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
164 using GridGeometry = std::decay_t<decltype(std::declval<GFVC>().problem().gridGeometry())>;
165 using GridView =
typename GridGeometry::GridView;
168 static constexpr std::size_t maxNumBoundaryFaces = GridView::dimension << 1;
178 : gridFluxVarsCachePtr_(&global) {}
182 template<
class FVElementGeometry,
class ElementVolumeVariables>
183 void bind(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
184 const FVElementGeometry& fvGeometry,
185 const ElementVolumeVariables& elemVolVars) &
187 bindElement(element, fvGeometry, elemVolVars);
195 template<
class FVElementGeometry,
class ElementVolumeVariables>
197 const FVElementGeometry& fvGeometry,
198 const ElementVolumeVariables& elemVolVars) &&
200 this->bind(element, fvGeometry, elemVolVars);
201 return std::move(*
this);
204 template<
class FVElementGeometry,
class ElementVolumeVariables>
205 void bindElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
206 const FVElementGeometry& fvGeometry,
207 const ElementVolumeVariables& elemVolVars) &
210 fluxVarsCache_.resize(fvGeometry.numScvf());
211 for (
auto&& scvf : scvfs(fvGeometry))
214 fluxVarsCache_[scvf.index()].resize(std::ranges::size(quadRule));
215 for (
const auto& qpData : quadRule)
216 fluxVarsCache_[scvf.index()][qpData.ipData().qpIndex()].update(
217 gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, qpData.ipData()
223 elementCache_.resize(std::ranges::size(elemQuadRule));
224 for (
const auto& qpData : elemQuadRule)
225 elementCache_[qpData.ipData().qpIndex()].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, qpData.ipData());
228 for (
const auto& boundaryFace : boundaryFaces(fvGeometry))
230 auto& bfCache = boundaryFaceCache_[boundaryFace.index()];
232 bfCache.resize(std::ranges::size(quadRule));
233 for (
const auto& qpData : quadRule)
234 bfCache[qpData.ipData().qpIndex()].update(gridFluxVarsCache().problem(),
247 template<
class FVElementGeometry,
class ElementVolumeVariables>
249 const FVElementGeometry& fvGeometry,
250 const ElementVolumeVariables& elemVolVars) &&
252 this->bindElement(element, fvGeometry, elemVolVars);
253 return std::move(*
this);
256 template<
class FVElementGeometry,
class ElementVolumeVariables>
257 void bindScvf(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
258 const FVElementGeometry& fvGeometry,
259 const ElementVolumeVariables& elemVolVars,
260 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
262 fluxVarsCache_.resize(fvGeometry.numScvf());
264 fluxVarsCache_[scvf.index()].resize(std::ranges::size(quadRule));
265 for (
const auto& qpData : quadRule)
266 fluxVarsCache_[scvf.index()][qpData.ipData().qpIndex()].update(
267 gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, qpData.ipData()
276 template<
class FVElementGeometry,
class ElementVolumeVariables>
278 const FVElementGeometry& fvGeometry,
279 const ElementVolumeVariables& elemVolVars,
280 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
282 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
283 return std::move(*
this);
290 template<
class FVElementGeometry,
class ElementVolumeVariables>
291 void update(
const typename FVElementGeometry::Element& element,
292 const FVElementGeometry& fvGeometry,
293 const ElementVolumeVariables& elemVolVars)
295 if constexpr (FluxVariablesCache::isSolDependent)
296 bindElement(element, fvGeometry, elemVolVars);
300 template<Concept::ScvfQpIpData IpData>
302 {
return fluxVarsCache_[ipData.scvfIndex()][ipData.qpIndex()]; }
305 template<Concept::ScvfQpIpData IpData>
307 {
return fluxVarsCache_[ipData.scvfIndex()][ipData.qpIndex()]; }
310 template<Concept::BoundaryFaceQpIpData IpData>
312 {
return boundaryFaceCache_[ipData.boundaryFaceIndex()][ipData.qpIndex()]; }
315 template<Concept::BoundaryFaceQpIpData IpData>
317 {
return boundaryFaceCache_[ipData.boundaryFaceIndex()][ipData.qpIndex()]; }
320 template<Concept::QIpData IpData>
322 {
return elementCache_[ipData.qpIndex()]; }
325 template<Concept::QIpData IpData>
327 {
return elementCache_[ipData.qpIndex()]; }
331 {
return *gridFluxVarsCachePtr_; }
334 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
335 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
336 std::vector<FluxVariablesCache> elementCache_;
337 std::array<std::vector<FluxVariablesCache>, maxNumBoundaryFaces> boundaryFaceCache_;
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:248
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:330
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/hybrid/elementfluxvariablescache.hh:291
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:172
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:183
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:175
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/hybrid/elementfluxvariablescache.hh:257
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:196
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:277
HybridCVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:177
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:205
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:112
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:52
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:49
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/hybrid/elementfluxvariablescache.hh:100
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:80
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:149
HybridCVFEElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:54
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/hybrid/elementfluxvariablescache.hh:123
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:91
HybridCVFEElementFluxVariablesCache 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/hybrid/elementfluxvariablescache.hh:71
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:60
The flux variables caches for an element when using hybrid CVFE discretizations.
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:38
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition: quadraturerules.hh:159
Quadrature rules over sub-control volumes and sub-control volume faces.