12#ifndef DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
27template<
class P,
class FVC,
class FVCF>
34 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
43template<
class Problem,
44 class FluxVariablesCache,
45 class FluxVariablesCacheFiller,
46 bool EnableGridFluxVariablesCache =
false,
55template<
class P,
class FVC,
class FVCF,
class TheTraits>
58 using Problem =
typename TheTraits::Problem;
62 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
71 static constexpr bool cachingEnabled =
true;
80 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
81 void update(
const GridGeometry& gridGeometry,
82 const GridVolumeVariables& gridVolVars,
83 const SolutionVector& sol,
84 bool forceUpdate =
false)
87 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
90 FluxVariablesCacheFiller filler(problem());
92 fluxVarsCache_.resize(gridGeometry.numScvf());
97 const auto element = gridGeometry.element(eIdx);
98 const auto fvGeometry = localView(gridGeometry).bind(element);
99 const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol);
101 for (auto&& scvf : scvfs(fvGeometry))
103 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
109 template<
class FVElementGeometry,
class ElementVolumeVariables>
110 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
111 const FVElementGeometry& fvGeometry,
112 const ElementVolumeVariables& elemVolVars)
114 if (FluxVariablesCacheFiller::isSolDependent)
116 const auto globalI = fvGeometry.gridGeometry().elementMapper().index(element);
119 FluxVariablesCacheFiller filler(problem());
122 for (
const auto& scvf : scvfs(fvGeometry))
123 filler.fill(*
this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf);
126 for (
const auto& dataJ : fvGeometry.gridGeometry().connectivityMap()[globalI])
128 const auto elementJ = fvGeometry.gridGeometry().element(dataJ.globalJ);
129 for (
const auto scvfIdxJ : dataJ.scvfsJ)
131 const auto& scvfJ = fvGeometry.scvf(scvfIdxJ);
132 filler.fill(*
this, fluxVarsCache_[scvfJ.index()], elementJ, fvGeometry, elemVolVars, scvfJ);
139 template<
class SubControlVolumeFace>
141 {
return fluxVarsCache_[scvf.index()]; }
143 template<
class SubControlVolumeFace>
145 {
return fluxVarsCache_[scvf.index()]; }
148 {
return *problemPtr_; }
151 const Problem* problemPtr_;
153 std::vector<FluxVariablesCache> fluxVarsCache_;
154 std::vector<std::size_t> globalScvfIndices_;
161template<
class P,
class FVC,
class FVCF,
class TheTraits>
164 using Problem =
typename TheTraits::Problem;
168 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
177 static constexpr bool cachingEnabled =
false;
186 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
187 void update(
const GridGeometry& gridGeometry,
188 const GridVolumeVariables& gridVolVars,
189 const SolutionVector& sol,
190 bool forceUpdate =
false) {}
193 template<
class FVElementGeometry,
class ElementVolumeVariables>
194 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
195 const FVElementGeometry& fvGeometry,
196 const ElementVolumeVariables& elemVolVars) {}
199 {
return *problemPtr_; }
202 const Problem* problemPtr_;
The flux variables caches for an element.
Definition: discretization/cellcentered/tpfa/elementfluxvariablescache.hh:33
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:163
void updateElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
When global flux variables caching is disabled, we don't need to update the cache.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:194
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
When global flux variables caching is disabled, we don't need to update the cache.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:187
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:174
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:183
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:180
TheTraits Traits
the flux variables cache traits
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:171
const Problem & problem() const
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:198
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:57
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:81
void updateElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:110
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:77
TheTraits Traits
the flux variables cache traits
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:65
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:74
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:68
const Problem & problem() const
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:147
Flux variable caches on a gridview.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:48
The flux variables caches for an element.
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/cellcentered/tpfa/gridfluxvariablescache.hh:29
FVCF FluxVariablesCacheFiller
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:32
P Problem
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:30
FVC FluxVariablesCache
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:31