24#ifndef DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
37template<
class P,
class FVC,
class FVCF>
44 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
53template<
class Problem,
54 class FluxVariablesCache,
55 class FluxVariablesCacheFiller,
56 bool EnableGridFluxVariablesCache =
false,
65template<
class P,
class FVC,
class FVCF,
class TheTraits>
68 using Problem =
typename TheTraits::Problem;
72 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
81 static constexpr bool cachingEnabled =
true;
90 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
91 void update(
const GridGeometry& gridGeometry,
92 const GridVolumeVariables& gridVolVars,
93 const SolutionVector& sol,
94 bool forceUpdate =
false)
97 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
100 FluxVariablesCacheFiller filler(problem());
102 fluxVarsCache_.resize(gridGeometry.numScvf());
103 for (
const auto& element : elements(gridGeometry.gridView()))
106 auto fvGeometry =
localView(gridGeometry);
107 fvGeometry.bind(element);
109 auto elemVolVars =
localView(gridVolVars);
110 elemVolVars.bind(element, fvGeometry, sol);
112 for (
auto&& scvf : scvfs(fvGeometry))
114 filler.fill(*
this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
120 template<
class FVElementGeometry,
class ElementVolumeVariables>
121 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
122 const FVElementGeometry& fvGeometry,
123 const ElementVolumeVariables& elemVolVars)
125 if (FluxVariablesCacheFiller::isSolDependent)
127 const auto globalI = fvGeometry.gridGeometry().elementMapper().index(element);
130 FluxVariablesCacheFiller filler(problem());
133 for (
const auto& scvf : scvfs(fvGeometry))
134 filler.fill(*
this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf);
137 for (
const auto& dataJ : fvGeometry.gridGeometry().connectivityMap()[globalI])
139 const auto elementJ = fvGeometry.gridGeometry().element(dataJ.globalJ);
140 for (
const auto scvfIdxJ : dataJ.scvfsJ)
142 const auto& scvfJ = fvGeometry.scvf(scvfIdxJ);
143 filler.fill(*
this, fluxVarsCache_[scvfJ.index()], elementJ, fvGeometry, elemVolVars, scvfJ);
150 template<
class SubControlVolumeFace>
152 {
return fluxVarsCache_[scvf.index()]; }
154 template<
class SubControlVolumeFace>
156 {
return fluxVarsCache_[scvf.index()]; }
159 {
return *problemPtr_; }
162 const Problem* problemPtr_;
164 std::vector<FluxVariablesCache> fluxVarsCache_;
165 std::vector<std::size_t> globalScvfIndices_;
172template<
class P,
class FVC,
class FVCF,
class TheTraits>
175 using Problem =
typename TheTraits::Problem;
179 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
188 static constexpr bool cachingEnabled =
false;
197 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
198 void update(
const GridGeometry& gridGeometry,
199 const GridVolumeVariables& gridVolVars,
200 const SolutionVector& sol,
201 bool forceUpdate =
false) {}
204 template<
class FVElementGeometry,
class ElementVolumeVariables>
205 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
206 const FVElementGeometry& fvGeometry,
207 const ElementVolumeVariables& elemVolVars) {}
210 {
return *problemPtr_; }
213 const Problem* problemPtr_;
Free function to get the local view of a grid cache object.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: cellcentered/tpfa/elementfluxvariablescache.hh:43
Flux variable caches traits.
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:39
FVCF FluxVariablesCacheFiller
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:42
P Problem
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:40
FVC FluxVariablesCache
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:41
Flux variable caches on a gridview.
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:58
Flux variable caches on a gridview with grid caching enabled.
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:67
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:91
void updateElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:121
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:87
TheTraits Traits
the flux variables cache traits
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:75
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:84
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:78
const Problem & problem() const
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:158
Flux variable caches on a gridview with grid caching disabled.
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:174
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: cellcentered/tpfa/gridfluxvariablescache.hh:205
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: cellcentered/tpfa/gridfluxvariablescache.hh:198
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:185
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:194
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:191
TheTraits Traits
the flux variables cache traits
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:182
const Problem & problem() const
Definition: cellcentered/tpfa/gridfluxvariablescache.hh:209
The flux variables caches for an element.