24#ifndef DUMUX_DISCRETIZATION_CCMPFA_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_CCMPFA_GRID_FLUXVARSCACHE_HH
37template<
class ModelTraits>
44 static constexpr int numPhases = ModelTraits::numFluidPhases();
53 class FVC,
class FVCF,
67 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
84template<
class Traits,
bool cachingEnabled>
92template<
class TheTraits>
95 using Problem =
typename TheTraits::Problem;
99 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
116 static constexpr bool cachingEnabled =
true;
123 : problemPtr_(&problem)
127 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
128 void update(
const GridGeometry& gridGeometry,
129 const GridVolumeVariables& gridVolVars,
130 const SolutionVector& sol,
131 bool forceUpdate =
false)
135 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
142 const auto& gridIvIndexSets = gridGeometry.gridInteractionVolumeIndexSets();
143 const auto numPrimaryIvs = gridIvIndexSets.numPrimaryInteractionVolumes();
144 const auto numSecondaryIVs = gridIvIndexSets.numSecondaryInteractionVolumes();
145 ivDataStorage_.primaryInteractionVolumes.reserve(numPrimaryIvs);
146 ivDataStorage_.secondaryInteractionVolumes.reserve(numSecondaryIVs);
147 ivDataStorage_.primaryDataHandles.reserve(numPrimaryIvs);
148 ivDataStorage_.secondaryDataHandles.reserve(numSecondaryIVs);
151 fluxVarsCache_.resize(gridGeometry.numScvf());
155 FluxVariablesCacheFiller filler(problem());
158 for (
auto& cache : fluxVarsCache_)
159 cache.setUpdateStatus(
false);
161 auto fvGeometry =
localView(gridGeometry);
162 auto elemVolVars =
localView(gridVolVars);
163 for (
const auto& element : elements(gridGeometry.gridView()))
165 fvGeometry.bind(element);
166 elemVolVars.bind(element, fvGeometry, sol);
170 for (
const auto& scvf : scvfs(fvGeometry))
171 if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !fluxVarsCache_[scvf.index()].isUpdated())
172 filler.fill(*
this, fluxVarsCache_[scvf.index()], ivDataStorage_, fvGeometry, elemVolVars, scvf, forceUpdate);
177 template<
class FVElementGeometry,
class ElementVolumeVariables>
178 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
179 const FVElementGeometry& fvGeometry,
180 const ElementVolumeVariables& elemVolVars)
184 if (FluxVariablesCacheFiller::isSolDependent)
186 const auto& gridGeometry = fvGeometry.gridGeometry();
187 const auto& assemblyMapI = gridGeometry.connectivityMap()[gridGeometry.elementMapper().index(element)];
190 FluxVariablesCacheFiller filler(problem());
193 for (
const auto& scvf : scvfs(fvGeometry))
194 fluxVarsCache_[scvf.index()].setUpdateStatus(
false);
195 for (
const auto& dataJ : assemblyMapI)
196 for (
const auto scvfIdx : dataJ.scvfsJ)
197 fluxVarsCache_[scvfIdx].setUpdateStatus(
false);
200 for (
const auto& scvf : scvfs(fvGeometry))
202 auto& scvfCache = fluxVarsCache_[scvf.index()];
203 if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !scvfCache.isUpdated())
204 filler.fill(*
this, scvfCache, ivDataStorage_, fvGeometry, elemVolVars, scvf);
207 for (
const auto& dataJ : assemblyMapI)
209 for (
const auto scvfIdx : dataJ.scvfsJ)
211 auto& scvfCache = fluxVarsCache_[scvfIdx];
212 const auto& scvf = fvGeometry.scvf(scvfIdx);
213 if (!isEmbeddedInBoundaryIV_(scvf, gridGeometry) && !scvfCache.isUpdated())
214 filler.fill(*
this, scvfCache, ivDataStorage_, fvGeometry, elemVolVars, scvf);
221 template<
class SubControlVolumeFace>
223 {
return fluxVarsCache_[scvf.index()]; }
226 template<
class SubControlVolumeFace>
228 {
return fluxVarsCache_[scvf.index()]; }
231 template<
class SubControlVolumeFace>
233 {
return ivDataStorage_.primaryInteractionVolumes[ (*this)[scvf].ivIndexInContainer() ]; }
236 template<
class SubControlVolumeFace>
238 {
return ivDataStorage_.primaryDataHandles[ (*this)[scvf].ivIndexInContainer() ]; }
241 template<
class SubControlVolumeFace>
243 {
return ivDataStorage_.secondaryInteractionVolumes[ (*this)[scvf].ivIndexInContainer() ]; }
246 template<
class SubControlVolumeFace>
248 {
return ivDataStorage_.secondaryDataHandles[ (*this)[scvf].ivIndexInContainer() ]; }
251 {
return *problemPtr_; }
255 template<
class SubControlVolumeFace,
class Gr
idGeometry>
256 bool isEmbeddedInBoundaryIV_(
const SubControlVolumeFace& scvf,
const GridGeometry& gridGeometry)
const
258 const auto& gridIvIndexSets = gridGeometry.gridInteractionVolumeIndexSets();
259 if (gridGeometry.vertexUsesSecondaryInteractionVolume(scvf.vertexIndex()))
260 return gridIvIndexSets.secondaryIndexSet(scvf).nodalIndexSet().numBoundaryScvfs() > 0;
262 return gridIvIndexSets.primaryIndexSet(scvf).nodalIndexSet().numBoundaryScvfs() > 0;
268 fluxVarsCache_.clear();
269 ivDataStorage_.primaryInteractionVolumes.clear();
270 ivDataStorage_.secondaryInteractionVolumes.clear();
271 ivDataStorage_.primaryDataHandles.clear();
272 ivDataStorage_.secondaryDataHandles.clear();
275 const Problem* problemPtr_;
276 std::vector<FluxVariablesCache> fluxVarsCache_;
279 using IVDataStorage = InteractionVolumeDataStorage<PrimaryInteractionVolume,
281 SecondaryInteractionVolume,
282 SecondaryIvDataHandle>;
283 IVDataStorage ivDataStorage_;
290template<
class TheTraits>
293 using Problem =
typename TheTraits::Problem;
297 using FluxVariablesCacheFiller =
typename TheTraits::FluxVariablesCacheFiller;
314 static constexpr bool cachingEnabled =
false;
323 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
324 void update(
const GridGeometry& gridGeometry,
325 const GridVolumeVariables& gridVolVars,
326 const SolutionVector& sol,
327 bool forceUpdate =
false) {}
330 template<
class FVElementGeometry,
class ElementVolumeVariables>
331 void updateElement(
const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
332 const FVElementGeometry& fvGeometry,
333 const ElementVolumeVariables& elemVolVars) {}
336 {
return *problemPtr_; }
339 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
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/mpfa/elementfluxvariablescache.hh:62
Data handle physics traits.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:39
static constexpr bool enableHeatConduction
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:42
static constexpr bool enableMolecularDiffusion
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:41
static constexpr int numPhases
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:44
static constexpr bool enableAdvection
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:40
static constexpr int numComponents
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:45
Data handle physics traits.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:57
FVCF FluxVariablesCacheFiller
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:60
P Problem
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:58
FVC FluxVariablesCache
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:59
SDH SecondaryIvDataHandle
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:65
static constexpr std::size_t maxLocalElementLevelDifference()
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:75
PIV PrimaryInteractionVolume
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:62
PDH PrimaryIvDataHandle
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:64
SIV SecondaryInteractionVolume
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:63
Flux variable caches on a gridview.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:85
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:94
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
When global caching is enabled, precompute transmissibilities for all scv faces.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:128
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:119
typename Traits::PrimaryInteractionVolume PrimaryInteractionVolume
export the interaction volume types
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:105
const Problem & problem() const
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:250
CCMpfaGridFluxVariablesCache(const Problem &problem)
The constructor.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:122
const SecondaryIvDataHandle & secondaryDataHandle(const SubControlVolumeFace &scvf) const
access to the data handle of an interaction volume an scvf is embedded in
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:247
TheTraits Traits
export the Traits
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:102
typename Traits::PrimaryIvDataHandle PrimaryIvDataHandle
export the data handle types used
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:109
const SecondaryInteractionVolume & secondaryInteractionVolume(const SubControlVolumeFace &scvf) const
access to the interaction volume an scvf is embedded in
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:242
typename Traits::SecondaryInteractionVolume SecondaryInteractionVolume
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:106
const PrimaryIvDataHandle & primaryDataHandle(const SubControlVolumeFace &scvf) const
access to the data handle of an interaction volume an scvf is embedded in
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:237
typename Traits::SecondaryIvDataHandle SecondaryIvDataHandle
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:110
const PrimaryInteractionVolume & primaryInteractionVolume(const SubControlVolumeFace &scvf) const
access to the interaction volume an scvf is embedded in
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:232
void updateElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:178
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:113
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:292
const Problem & problem() const
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:335
typename Traits::PrimaryInteractionVolume PrimaryInteractionVolume
export the interaction volume types
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:303
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/mpfa/gridfluxvariablescache.hh:331
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:317
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/mpfa/gridfluxvariablescache.hh:324
typename Traits::PrimaryIvDataHandle PrimaryIvDataHandle
export the data handle types used
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:307
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:311
typename Traits::SecondaryInteractionVolume SecondaryInteractionVolume
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:304
TheTraits Traits
export the Traits
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:300
CCMpfaGridFluxVariablesCache(const Problem &problem)
The constructor.
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:320
typename Traits::SecondaryIvDataHandle SecondaryIvDataHandle
Definition: discretization/cellcentered/mpfa/gridfluxvariablescache.hh:308
The element-local object of flux variables caches.