12#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
29template<
class P,
class FVC>
35 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
44template<
class Problem,
45 class FluxVariablesCache,
48 class ScvfQuadratureRule>
55template<
class Problem,
56 class FluxVariablesCache,
57 bool cachingEnabled =
false,
68template<
class P,
class FVC,
class Traits>
71 using Problem =
typename Traits::Problem;
86 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
87 void update(
const GridGeometry& gridGeometry,
88 const GridVolumeVariables& gridVolVars,
89 const SolutionVector& sol,
90 bool forceUpdate =
false)
95 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
99 const auto element = gridGeometry.element(eIdx);
100 const auto fvGeometry =
localView(gridGeometry).bind(element);
101 const auto elemVolVars =
localView(gridVolVars).bind(element, fvGeometry, sol);
104 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
105 for (
const auto& scvf : scvfs(fvGeometry))
106 cache(eIdx, scvf.index()).update(
problem, element, fvGeometry, elemVolVars, scvf);
111 template<
class FVElementGeometry,
class ElementVolumeVariables>
113 const FVElementGeometry& fvGeometry,
114 const ElementVolumeVariables& elemVolVars)
116 if constexpr (FluxVariablesCache::isSolDependent)
118 const auto& gridDiscretization = Deprecated::gridGeometry(fvGeometry);
119 const auto eIdx = gridDiscretization.elementMapper().index(element);
120 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
121 for (
const auto& scvf : scvfs(fvGeometry))
122 cache(eIdx, scvf.index()).update(
problem(), element, fvGeometry, elemVolVars, scvf);
127 {
return *problemPtr_; }
131 {
return fluxVarsCache_[eIdx][scvfIdx]; }
135 {
return fluxVarsCache_[eIdx][scvfIdx]; }
139 const Problem* problemPtr_;
140 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
149template<
class P,
class FVC,
class Traits,
class ScvfQR>
152 using Problem =
typename Traits::Problem;
167 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
168 void update(
const GridGeometry& gridGeometry,
169 const GridVolumeVariables& gridVolVars,
170 const SolutionVector& sol,
171 bool forceUpdate =
false)
176 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
177 qpsOffset_.resize(gridGeometry.gridView().size(0));
181 const auto element = gridGeometry.element(eIdx);
182 const auto fvGeometry =
localView(gridGeometry).bind(element);
183 const auto elemVolVars =
localView(gridVolVars).bind(element, fvGeometry, sol);
186 qpsOffset_[eIdx].resize(fvGeometry.numScvf() + 1, 0);
187 for (
const auto& scvf : scvfs(fvGeometry))
190 qpsOffset_[eIdx][scvf.index() + 1] = numQps;
192 for (std::size_t i = 2; i < qpsOffset_[eIdx].size(); ++i)
193 qpsOffset_[eIdx][i] += qpsOffset_[eIdx][i-1];
196 fluxVarsCache_[eIdx].resize(qpsOffset_[eIdx].back());
197 for (
const auto& scvf : scvfs(fvGeometry))
200 cache(eIdx, qpData.ipData().scvfIndex(), qpData.ipData().qpIndex()).update(
problem,
210 template<
class FVElementGeometry,
class ElementVolumeVariables>
212 const FVElementGeometry& fvGeometry,
213 const ElementVolumeVariables& elemVolVars)
215 if constexpr (FluxVariablesCache::isSolDependent)
217 const auto& gridDiscretization = Deprecated::gridGeometry(fvGeometry);
218 const auto eIdx = gridDiscretization.elementMapper().index(element);
221 qpsOffset_[eIdx].resize(fvGeometry.numScvf() + 1, 0);
222 for (
const auto& scvf : scvfs(fvGeometry))
225 qpsOffset_[eIdx][scvf.index() + 1] = numQps;
227 for (std::size_t i = 2; i < qpsOffset_[eIdx].size(); ++i)
228 qpsOffset_[eIdx][i] += qpsOffset_[eIdx][i-1];
231 fluxVarsCache_[eIdx].resize(qpsOffset_[eIdx].back());
232 for (
const auto& scvf : scvfs(fvGeometry))
235 cache(eIdx, qpData.ipData().scvfIndex(), qpData.ipData().qpIndex()).update(
problem(),
245 {
return *problemPtr_; }
249 {
return fluxVarsCache_[eIdx][qpsOffset_[eIdx][scvfIdx] + qpIdx]; }
253 {
return fluxVarsCache_[eIdx][qpsOffset_[eIdx][scvfIdx] + qpIdx]; }
257 const Problem* problemPtr_;
258 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
259 std::vector<std::vector<std::size_t>> qpsOffset_;
266template<
class P,
class FVC,
class Traits,
class ScvfQR>
269 using Problem =
typename Traits::Problem;
284 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
285 void update(
const GridGeometry& gridGeometry,
286 const GridVolumeVariables& gridVolVars,
287 const SolutionVector& sol,
288 bool forceUpdate =
false) {}
291 {
return *problemPtr_; }
294 const Problem* problemPtr_;
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition discretization/cvfe/gridfluxvariablescache.hh:282
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition discretization/cvfe/gridfluxvariablescache.hh:274
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition discretization/cvfe/gridfluxvariablescache.hh:280
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition discretization/cvfe/gridfluxvariablescache.hh:285
const Problem & problem() const
Definition discretization/cvfe/gridfluxvariablescache.hh:290
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition discretization/cvfe/gridfluxvariablescache.hh:277
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition discretization/cvfe/gridfluxvariablescache.hh:165
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition discretization/cvfe/gridfluxvariablescache.hh:160
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition discretization/cvfe/gridfluxvariablescache.hh:157
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx)
Definition discretization/cvfe/gridfluxvariablescache.hh:252
const Problem & problem() const
Definition discretization/cvfe/gridfluxvariablescache.hh:244
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition discretization/cvfe/gridfluxvariablescache.hh:211
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition discretization/cvfe/gridfluxvariablescache.hh:163
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx, std::size_t qpIdx) const
Definition discretization/cvfe/gridfluxvariablescache.hh:248
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition discretization/cvfe/gridfluxvariablescache.hh:168
const Problem & problem() const
Definition discretization/cvfe/gridfluxvariablescache.hh:126
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition discretization/cvfe/gridfluxvariablescache.hh:112
static constexpr bool cachingEnabled
make it possible to query if caching is enabled
Definition discretization/cvfe/gridfluxvariablescache.hh:79
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition discretization/cvfe/gridfluxvariablescache.hh:130
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition discretization/cvfe/gridfluxvariablescache.hh:82
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition discretization/cvfe/gridfluxvariablescache.hh:87
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition discretization/cvfe/gridfluxvariablescache.hh:76
CVFEGridFluxVariablesCacheImpl(const Problem &problem)
Definition discretization/cvfe/gridfluxvariablescache.hh:84
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition discretization/cvfe/gridfluxvariablescache.hh:134
Flux variable caches implementation on a gridview.
Definition discretization/cvfe/gridfluxvariablescache.hh:49
Global flux variable cache.
CVFEElementFluxVariablesCacheImpl< GFVC, cachingEnabled, Detail::ScvfQuadratureRuleOrDefault_t< typename GFVC::FluxVariablesCache > > CVFEElementFluxVariablesCache
The flux variables caches for an element.
Definition discretization/cvfe/elementfluxvariablescache.hh:56
CVFEGridFluxVariablesCacheImpl< Problem, FluxVariablesCache, cachingEnabled, Traits, Detail::ScvfQuadratureRuleOrDefault_t< typename Traits::FluxVariablesCache > > CVFEGridFluxVariablesCache
Flux variable caches on a gridview.
Definition discretization/cvfe/gridfluxvariablescache.hh:59
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:159
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesScvfQuadratureRule, FluxVariablesCache > ScvfQuadratureRuleOrDefault_t
Definition discretization/cvfe/elementfluxvariablescache.hh:33
Definition quadraturerules.hh:52
Parallel for loop (multithreading).
Quadrature rules over sub-control volumes and sub-control volume faces.
Flux variable caches traits.
Definition discretization/cvfe/gridfluxvariablescache.hh:31
P Problem
Definition discretization/cvfe/gridfluxvariablescache.hh:32
FVC FluxVariablesCache
Definition discretization/cvfe/gridfluxvariablescache.hh:33
CVFEElementFluxVariablesCache< GridFluxVariablesCache, cachingEnabled > LocalView
Definition discretization/cvfe/gridfluxvariablescache.hh:36