12#ifndef DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_CVFE_GRID_FLUXVARSCACHE_HH
27template<
class P,
class FVC>
33 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
42template<
class Problem,
43 class FluxVariablesCache,
44 bool cachingEnabled =
false,
53template<
class P,
class FVC,
class Traits>
56 using Problem =
typename Traits::Problem;
64 static constexpr bool cachingEnabled =
true;
71 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
72 void update(
const GridGeometry& gridGeometry,
73 const GridVolumeVariables& gridVolVars,
74 const SolutionVector& sol,
75 bool forceUpdate =
false)
80 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
81 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](
const std::size_t eIdx)
84 const auto element = gridGeometry.element(eIdx);
85 const auto fvGeometry =
localView(gridGeometry).bind(element);
86 const auto elemVolVars =
localView(gridVolVars).bind(element, fvGeometry, sol);
89 fluxVarsCache_[eIdx].resize(fvGeometry.numScvf());
90 for (
const auto& scvf : scvfs(fvGeometry))
91 cache(eIdx, scvf.index()).update(problem, element, fvGeometry, elemVolVars, scvf);
96 template<
class FVElementGeometry,
class ElementVolumeVariables>
98 const FVElementGeometry& fvGeometry,
99 const ElementVolumeVariables& elemVolVars)
101 if constexpr (FluxVariablesCache::isSolDependent)
103 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
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 {
return *problemPtr_; }
115 {
return fluxVarsCache_[eIdx][scvfIdx]; }
119 {
return fluxVarsCache_[eIdx][scvfIdx]; }
123 const Problem* problemPtr_;
124 std::vector<std::vector<FluxVariablesCache>> fluxVarsCache_;
131template<
class P,
class FVC,
class Traits>
134 using Problem =
typename Traits::Problem;
142 static constexpr bool cachingEnabled =
false;
149 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
150 void update(
const GridGeometry& gridGeometry,
151 const GridVolumeVariables& gridVolVars,
152 const SolutionVector& sol,
153 bool forceUpdate =
false) {}
156 {
return *problemPtr_; }
159 const Problem* problemPtr_;
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:31
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cvfe/gridfluxvariablescache.hh:133
CVFEGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:147
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:155
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:145
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:139
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:150
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/cvfe/gridfluxvariablescache.hh:55
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition: discretization/cvfe/gridfluxvariablescache.hh:118
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cvfe/gridfluxvariablescache.hh:61
const Problem & problem() const
Definition: discretization/cvfe/gridfluxvariablescache.hh:110
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cvfe/gridfluxvariablescache.hh:97
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition: discretization/cvfe/gridfluxvariablescache.hh:114
CVFEGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cvfe/gridfluxvariablescache.hh:69
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cvfe/gridfluxvariablescache.hh:67
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cvfe/gridfluxvariablescache.hh:72
Flux variable caches on a gridview.
Definition: discretization/cvfe/gridfluxvariablescache.hh:46
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.
Parallel for loop (multithreading)
Flux variable caches traits.
Definition: discretization/cvfe/gridfluxvariablescache.hh:29
P Problem
Definition: discretization/cvfe/gridfluxvariablescache.hh:30
FVC FluxVariablesCache
Definition: discretization/cvfe/gridfluxvariablescache.hh:31