12#ifndef DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
13#define DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
27template<
class P,
class FVC,
class IS = TwoPInvasionState<P>>
34 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
43template<
class Problem,
44 class FluxVariablesCache,
54template<
class P,
class FVC,
class Traits>
57 using Problem =
typename Traits::Problem;
59 using InvasionState =
typename Traits::InvasionState;
66 static constexpr bool cachingEnabled =
true;
72 : problemPtr_(&problem)
73 , invasionState_(problem) {}
75 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
77 const GridVolumeVariables& gridVolVars,
78 const SolutionVector& sol,
79 bool forceUpdate =
true)
81 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
82 auto fvGeometry =
localView(gridGeometry);
83 auto elemVolVars =
localView(gridVolVars);
84 for (
const auto& element : elements(gridGeometry.gridView()))
86 auto eIdx = gridGeometry.elementMapper().index(element);
89 fvGeometry.bind(element);
90 elemVolVars.bind(element, fvGeometry, sol);
92 for (
auto&& scvf : scvfs(fvGeometry))
93 cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf, invasionState().invaded(element));
97 template<
class FVElementGeometry,
class ElementVolumeVariables>
99 const FVElementGeometry& fvGeometry,
100 const ElementVolumeVariables& elemVolVars)
102 if constexpr (FluxVariablesCache::isSolDependent)
104 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
105 for (
const auto& scvf : scvfs(fvGeometry))
106 cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf, invasionState().invaded(element));
111 {
return *problemPtr_; }
115 {
return fluxVarsCache_[eIdx]; }
119 {
return fluxVarsCache_[eIdx]; }
122 {
return invasionState_; }
125 {
return invasionState_; }
128 const Problem* problemPtr_;
129 std::vector<FluxVariablesCache> fluxVarsCache_;
130 InvasionState invasionState_;
138template<
class P,
class FVC,
class Traits>
141 using Problem =
typename Traits::Problem;
143 using InvasionState =
typename Traits::InvasionState;
150 static constexpr bool cachingEnabled =
false;
156 : problemPtr_(&problem)
157 , invasionState_(problem) {}
159 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
161 const GridVolumeVariables& gridVolVars,
162 const SolutionVector& sol,
163 bool forceUpdate =
true) {}
166 {
return *problemPtr_; }
169 {
return invasionState_; }
172 {
return invasionState_; }
175 const Problem* problemPtr_;
176 InvasionState invasionState_;
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:477
The flux variables caches for an element.
Definition: porenetwork/2p/elementfluxvariablescache.hh:28
The grid flux variables cache for the two-phase PNM hodling the invasion state of the throats.
Definition: porenetwork/2p/gridfluxvariablescache.hh:140
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: porenetwork/2p/gridfluxvariablescache.hh:153
const Problem & problem() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:165
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: porenetwork/2p/gridfluxvariablescache.hh:147
InvasionState & invasionState()
Definition: porenetwork/2p/gridfluxvariablescache.hh:171
const InvasionState & invasionState() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:168
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=true)
Definition: porenetwork/2p/gridfluxvariablescache.hh:160
PNMTwoPGridFluxVariablesCache(const Problem &problem)
Definition: porenetwork/2p/gridfluxvariablescache.hh:155
The grid flux variables cache for the two-phase PNM hodling the invasion state of the throats.
Definition: porenetwork/2p/gridfluxvariablescache.hh:56
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition: porenetwork/2p/gridfluxvariablescache.hh:114
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=true)
Definition: porenetwork/2p/gridfluxvariablescache.hh:76
const Problem & problem() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:110
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition: porenetwork/2p/gridfluxvariablescache.hh:118
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: porenetwork/2p/gridfluxvariablescache.hh:69
InvasionState & invasionState()
Definition: porenetwork/2p/gridfluxvariablescache.hh:124
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: porenetwork/2p/gridfluxvariablescache.hh:63
void updateElement(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Definition: porenetwork/2p/gridfluxvariablescache.hh:98
const InvasionState & invasionState() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:121
PNMTwoPGridFluxVariablesCache(const Problem &problem)
Definition: porenetwork/2p/gridfluxvariablescache.hh:71
Flux variable caches on a gridview.
Definition: porenetwork/2p/gridfluxvariablescache.hh:47
Global flux variable cache.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Invasion state class for the two-phase PNM.
Free function to get the local view of a grid cache object.
Definition: discretization/porenetwork/fvelementgeometry.hh:24
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Element flux variable cache.
Flux variable caches traits.
Definition: porenetwork/2p/gridfluxvariablescache.hh:29
FVC FluxVariablesCache
Definition: porenetwork/2p/gridfluxvariablescache.hh:31
IS InvasionState
Definition: porenetwork/2p/gridfluxvariablescache.hh:32
P Problem
Definition: porenetwork/2p/gridfluxvariablescache.hh:30