24#ifndef DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_CCTPFA_GRID_FLUXVARSCACHE_HH
39template<
class P,
class FVC,
class FVCF>
46 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
55template<
class Problem,
56 class FluxVariablesCache,
57 class FluxVariablesCacheFiller,
58 bool EnableGridFluxVariablesCache =
false,
67template<
class P,
class FVC,
class FVCF,
class TheTraits>
70 using Problem =
typename TheTraits::Problem;
74 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
83 static constexpr bool cachingEnabled =
true;
92 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
93 void update(
const GridGeometry& gridGeometry,
94 const GridVolumeVariables& gridVolVars,
95 const SolutionVector& sol,
96 bool forceUpdate =
false)
99 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
102 FluxVariablesCacheFiller filler(problem());
104 fluxVarsCache_.resize(gridGeometry.numScvf());
109 const auto element = gridGeometry.element(eIdx);
110 const auto fvGeometry = localView(gridGeometry).bind(element);
111 const auto elemVolVars = localView(gridVolVars).bind(element, fvGeometry, sol);
113 for (auto&& scvf : scvfs(fvGeometry))
115 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
121 template<
class FVElementGeometry,
class ElementVolumeVariables>
122 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
123 const FVElementGeometry& fvGeometry,
124 const ElementVolumeVariables& elemVolVars)
126 if (FluxVariablesCacheFiller::isSolDependent)
128 const auto globalI = fvGeometry.gridGeometry().elementMapper().index(element);
131 FluxVariablesCacheFiller filler(problem());
134 for (
const auto& scvf : scvfs(fvGeometry))
135 filler.fill(*
this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf);
138 for (
const auto& dataJ : fvGeometry.gridGeometry().connectivityMap()[globalI])
140 const auto elementJ = fvGeometry.gridGeometry().element(dataJ.globalJ);
141 for (
const auto scvfIdxJ : dataJ.scvfsJ)
143 const auto& scvfJ = fvGeometry.scvf(scvfIdxJ);
144 filler.fill(*
this, fluxVarsCache_[scvfJ.index()], elementJ, fvGeometry, elemVolVars, scvfJ);
151 template<
class SubControlVolumeFace>
153 {
return fluxVarsCache_[scvf.index()]; }
155 template<
class SubControlVolumeFace>
157 {
return fluxVarsCache_[scvf.index()]; }
160 {
return *problemPtr_; }
163 const Problem* problemPtr_;
165 std::vector<FluxVariablesCache> fluxVarsCache_;
166 std::vector<std::size_t> globalScvfIndices_;
173template<
class P,
class FVC,
class FVCF,
class TheTraits>
176 using Problem =
typename TheTraits::Problem;
180 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
189 static constexpr bool cachingEnabled =
false;
198 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
199 void update(
const GridGeometry& gridGeometry,
200 const GridVolumeVariables& gridVolVars,
201 const SolutionVector& sol,
202 bool forceUpdate =
false) {}
205 template<
class FVElementGeometry,
class ElementVolumeVariables>
206 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
207 const FVElementGeometry& fvGeometry,
208 const ElementVolumeVariables& elemVolVars) {}
211 {
return *problemPtr_; }
214 const Problem* problemPtr_;
Free function to get the local view of a grid cache object.
Parallel for loop (multithreading)
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:172
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: discretization/cellcentered/tpfa/elementfluxvariablescache.hh:45
Flux variable caches traits.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:41
FVCF FluxVariablesCacheFiller
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:44
P Problem
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:42
FVC FluxVariablesCache
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:43
Flux variable caches on a gridview.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:60
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:69
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:93
void updateElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:122
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:89
TheTraits Traits
the flux variables cache traits
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:77
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:86
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:80
const Problem & problem() const
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:159
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:175
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:206
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:199
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:186
CCTpfaGridFluxVariablesCache(const Problem &problem)
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:195
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:192
TheTraits Traits
the flux variables cache traits
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:183
const Problem & problem() const
Definition: discretization/cellcentered/tpfa/gridfluxvariablescache.hh:210
The flux variables caches for an element.