12#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
28template<
class P,
class FVC>
34 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
43template<
class Problem,
44 class FluxVariablesCache,
47 class ScvfQuadratureRule>
54template<
class Problem,
55 class FluxVariablesCache,
56 bool cachingEnabled =
false,
67template<
class P,
class FVC,
class Traits>
70 using Problem =
typename Traits::Problem;
78 static constexpr bool cachingEnabled =
true;
85 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
86 void update(
const GridGeometry& gridGeometry,
87 const GridVolumeVariables& gridVolVars,
88 const SolutionVector& sol,
89 bool forceUpdate =
false)
94 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
95 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](
const std::size_t eIdx)
98 const auto element = gridGeometry.element(eIdx);
99 const auto fvGeometry =
localView(gridGeometry).bind(element);
100 const auto elemVolVars =
localView(gridVolVars).bind(element, fvGeometry, sol);
103 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
104 for (
const auto& scvf : scvfs(fvGeometry))
105 cache(eIdx, scvf.index()).update(problem, element, fvGeometry, elemVolVars, scvf);
110 template<
class FVElementGeometry,
class ElementVolumeVariables>
112 const FVElementGeometry& fvGeometry,
113 const ElementVolumeVariables& elemVolVars)
115 if constexpr (FluxVariablesCache::isSolDependent)
117 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
118 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
119 for (
const auto& scvf : scvfs(fvGeometry))
120 cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf);
125 {
return *problemPtr_; }
129 {
return fluxVarsCache_[eIdx][scvfIdx]; }
133 {
return fluxVarsCache_[eIdx][scvfIdx]; }
137 const Problem* problemPtr_;
138 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
147template<
class P,
class FVC,
class Traits,
class ScvfQR>
150 using Problem =
typename Traits::Problem;
158 static constexpr bool cachingEnabled =
true;
165 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
166 void update(
const GridGeometry& gridGeometry,
167 const GridVolumeVariables& gridVolVars,
168 const SolutionVector& sol,
169 bool forceUpdate =
false)
174 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
175 qpsOffset_.resize(gridGeometry.gridView().size(0));
176 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](
const std::size_t eIdx)
179 const auto element = gridGeometry.element(eIdx);
180 const auto fvGeometry =
localView(gridGeometry).bind(element);
181 const auto elemVolVars =
localView(gridVolVars).bind(element, fvGeometry, sol);
184 qpsOffset_[eIdx].resize(fvGeometry.numScvf() + 1, 0);
185 for (
const auto& scvf : scvfs(fvGeometry))
188 qpsOffset_[eIdx][scvf.index() + 1] = numQps;
190 for (std::size_t i = 2; i < qpsOffset_[eIdx].size(); ++i)
191 qpsOffset_[eIdx][i] += qpsOffset_[eIdx][i-1];
194 fluxVarsCache_[eIdx].resize(qpsOffset_[eIdx].back());
195 for (
const auto& scvf : scvfs(fvGeometry))
198 cache(eIdx, qpData.ipData().scvfIndex(), qpData.ipData().qpIndex()).update(problem,
208 template<
class FVElementGeometry,
class ElementVolumeVariables>
210 const FVElementGeometry& fvGeometry,
211 const ElementVolumeVariables& elemVolVars)
213 if constexpr (FluxVariablesCache::isSolDependent)
215 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
218 qpsOffset_[eIdx].resize(fvGeometry.numScvf() + 1, 0);
219 for (
const auto& scvf : scvfs(fvGeometry))
222 qpsOffset_[eIdx][scvf.index() + 1] = numQps;
224 for (std::size_t i = 2; i < qpsOffset_[eIdx].size(); ++i)
225 qpsOffset_[eIdx][i] += qpsOffset_[eIdx][i-1];
228 fluxVarsCache_[eIdx].resize(qpsOffset_[eIdx].back());
229 for (
const auto& scvf : scvfs(fvGeometry))
232 cache(eIdx, qpData.ipData().scvfIndex(), qpData.ipData().qpIndex()).update(problem(),
242 {
return *problemPtr_; }
246 {
return fluxVarsCache_[eIdx][qpsOffset_[eIdx][scvfIdx] + qpIdx]; }
250 {
return fluxVarsCache_[eIdx][qpsOffset_[eIdx][scvfIdx] + qpIdx]; }
254 const Problem* problemPtr_;
255 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
256 std::vector<std::vector<std::size_t>> qpsOffset_;
263template<
class P,
class FVC,
class Traits,
class ScvfQR>
266 using Problem =
typename Traits::Problem;
274 static constexpr bool cachingEnabled =
false;
281 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
282 void update(
const GridGeometry& gridGeometry,
283 const GridVolumeVariables& gridVolVars,
284 const SolutionVector& sol,
285 bool forceUpdate =
false) {}
288 {
return *problemPtr_; }
291 const Problem* problemPtr_;
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:48
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cvfe/gridfluxvariablescache.hh:265
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:279
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:271
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:277
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:282
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:287
Flux variable caches on a gridview with grid caching enabled (general quadrature specialization)
Definition: discretization/cvfe/gridfluxvariablescache.hh:149
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:163
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:155
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx)
Definition: discretization/cvfe/gridfluxvariablescache.hh:249
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:241
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cvfe/gridfluxvariablescache.hh:209
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:161
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx) const
Definition: discretization/cvfe/gridfluxvariablescache.hh:245
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:166
Flux variable caches on a gridview with grid caching enabled (MidpointQuadrature specialization)
Definition: discretization/cvfe/gridfluxvariablescache.hh:69
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:124
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cvfe/gridfluxvariablescache.hh:111
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition: discretization/cvfe/gridfluxvariablescache.hh:128
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:81
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:86
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:75
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:83
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition: discretization/cvfe/gridfluxvariablescache.hh:132
Flux variable caches implementation on a gridview.
Definition: discretization/cvfe/gridfluxvariablescache.hh:48
Global flux variable cache.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:160
Free function to get the local view of a grid cache object.
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition: quadraturerules.hh:148
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesScvfQuadratureRule, FluxVariablesCache > ScvfQuadratureRuleOrDefault_t
Definition: discretization/cvfe/elementfluxvariablescache.hh:34
Parallel for loop (multithreading)
Quadrature rules over sub-control volumes and sub-control volume faces.
Flux variable caches traits.
Definition: discretization/cvfe/gridfluxvariablescache.hh:30
P Problem
Definition: discretization/cvfe/gridfluxvariablescache.hh:31
FVC FluxVariablesCache
Definition: discretization/cvfe/gridfluxvariablescache.hh:32