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;
65 using Traits = TheTraits;
68 using FluxVariablesCache =
typename Traits::FluxVariablesCache;
71 static constexpr bool cachingEnabled =
true;
74 using LocalView =
typename Traits::template LocalView<ThisType, cachingEnabled>;
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>
140 const FluxVariablesCache& operator [](
const SubControlVolumeFace& scvf)
const
141 {
return fluxVarsCache_[scvf.index()]; }
143 template<
class SubControlVolumeFace>
144 FluxVariablesCache& operator [](
const SubControlVolumeFace& scvf)
145 {
return fluxVarsCache_[scvf.index()]; }
147 const Problem& problem()
const
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>
162class CCTpfaGridFluxVariablesCache<P, FVC, FVCF, false, TheTraits>
164 using Problem =
typename TheTraits::Problem;
165 using ThisType = CCTpfaGridFluxVariablesCache<P, FVC, FVCF, false, TheTraits>;
168 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
171 using Traits = TheTraits;
174 using FluxVariablesCache =
typename Traits::FluxVariablesCache;
177 static constexpr bool cachingEnabled =
false;
180 using LocalView =
typename Traits::template LocalView<ThisType, cachingEnabled>;
183 CCTpfaGridFluxVariablesCache(
const Problem& problem) : problemPtr_(&problem) {}
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) {}
198 const Problem& problem()
const
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.
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
CCTpfaElementFluxVariablesCache< GridFluxVariablesCache, cachingEnabled > LocalView
Definition discretization/cellcentered/tpfa/gridfluxvariablescache.hh:35
P Problem
Definition discretization/cellcentered/tpfa/gridfluxvariablescache.hh:30
FVC FluxVariablesCache
Definition discretization/cellcentered/tpfa/gridfluxvariablescache.hh:31