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::IntersectionQpIpData IpData>
138 return gridFluxVarsCache().boundaryIntersectionCache(eIdx_, ipData.intersectionIndex(), 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 maxNumIntersections = 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& intersection : intersections(fvGeometry.gridGeometry().gridView(), element))
230 const auto iIdx = intersection.indexInInside();
231 if (intersection.boundary())
233 auto& boundaryCache = boundaryIntersectionCache_[iIdx];
234 boundaryCache.emplace();
236 boundaryCache->resize(quadRule.size());
237 for (
const auto& qpData : quadRule)
238 (*boundaryCache)[qpData.ipData().qpIndex()].update(gridFluxVarsCache().problem(),
245 boundaryIntersectionCache_[iIdx].reset();
254 template<
class FVElementGeometry,
class ElementVolumeVariables>
256 const FVElementGeometry& fvGeometry,
257 const ElementVolumeVariables& elemVolVars) &&
259 this->bindElement(element, fvGeometry, elemVolVars);
260 return std::move(*
this);
263 template<
class FVElementGeometry,
class ElementVolumeVariables>
264 void bindScvf(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
265 const FVElementGeometry& fvGeometry,
266 const ElementVolumeVariables& elemVolVars,
267 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
269 fluxVarsCache_.resize(fvGeometry.numScvf());
271 fluxVarsCache_[scvf.index()].resize(std::ranges::size(quadRule));
272 for (
const auto& qpData : quadRule)
273 fluxVarsCache_[scvf.index()][qpData.ipData().qpIndex()].update(
274 gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, qpData.ipData()
283 template<
class FVElementGeometry,
class ElementVolumeVariables>
285 const FVElementGeometry& fvGeometry,
286 const ElementVolumeVariables& elemVolVars,
287 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
289 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
290 return std::move(*
this);
297 template<
class FVElementGeometry,
class ElementVolumeVariables>
298 void update(
const typename FVElementGeometry::Element& element,
299 const FVElementGeometry& fvGeometry,
300 const ElementVolumeVariables& elemVolVars)
302 if constexpr (FluxVariablesCache::isSolDependent)
303 bindElement(element, fvGeometry, elemVolVars);
307 template<Concept::ScvfQpIpData IpData>
309 {
return fluxVarsCache_[ipData.scvfIndex()][ipData.qpIndex()]; }
312 template<Concept::ScvfQpIpData IpData>
314 {
return fluxVarsCache_[ipData.scvfIndex()][ipData.qpIndex()]; }
317 template<Concept::IntersectionQpIpData IpData>
319 {
return (*boundaryIntersectionCache_[ipData.intersectionIndex()])[ipData.qpIndex()]; }
322 template<Concept::IntersectionQpIpData IpData>
324 {
return (*boundaryIntersectionCache_[ipData.intersectionIndex()])[ipData.qpIndex()]; }
327 template<Concept::QIpData IpData>
329 {
return elementCache_[ipData.qpIndex()]; }
332 template<Concept::QIpData IpData>
334 {
return elementCache_[ipData.qpIndex()]; }
338 {
return *gridFluxVarsCachePtr_; }
341 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
342 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
343 std::vector<FluxVariablesCache> elementCache_;
344 std::array<std::optional<std::vector<FluxVariablesCache>>, maxNumIntersections> boundaryIntersectionCache_;
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:255
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: discretization/cvfe/hybrid/elementfluxvariablescache.hh:337
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:298
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:264
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:284
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:148
Quadrature rules over sub-control volumes and sub-control volume faces.