24#ifndef DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
25#define DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
39template<
class P,
class FVC,
class IS = TwoPInvasionState<P>>
46 template<
class Gr
idFluxVariablesCache,
bool cachingEnabled>
55template<
class Problem,
56 class FluxVariablesCache,
66template<
class P,
class FVC,
class Traits>
69 using Problem =
typename Traits::Problem;
71 using InvasionState =
typename Traits::InvasionState;
78 static constexpr bool cachingEnabled =
true;
84 : problemPtr_(&problem)
85 , invasionState_(problem) {}
87 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
89 const GridVolumeVariables& gridVolVars,
90 const SolutionVector& sol,
91 bool forceUpdate =
true)
93 fluxVarsCache_.resize(gridGeometry.gridView().size(0));
94 auto fvGeometry =
localView(gridGeometry);
95 auto elemVolVars =
localView(gridVolVars);
96 for (
const auto& element : elements(gridGeometry.gridView()))
98 auto eIdx = gridGeometry.elementMapper().index(element);
101 fvGeometry.bind(element);
102 elemVolVars.bind(element, fvGeometry, sol);
104 for (
auto&& scvf : scvfs(fvGeometry))
105 cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf, invasionState().invaded(element));
110 {
return *problemPtr_; }
114 {
return fluxVarsCache_[eIdx]; }
118 {
return fluxVarsCache_[eIdx]; }
121 {
return invasionState_; }
124 {
return invasionState_; }
127 const Problem* problemPtr_;
128 std::vector<FluxVariablesCache> fluxVarsCache_;
129 InvasionState invasionState_;
137template<
class P,
class FVC,
class Traits>
140 using Problem =
typename Traits::Problem;
142 using InvasionState =
typename Traits::InvasionState;
149 static constexpr bool cachingEnabled =
false;
155 : problemPtr_(&problem)
156 , invasionState_(problem) {}
158 template<
class Gr
idGeometry,
class Gr
idVolumeVariables,
class SolutionVector>
160 const GridVolumeVariables& gridVolVars,
161 const SolutionVector& sol,
162 bool forceUpdate =
true) {}
165 {
return *problemPtr_; }
168 {
return invasionState_; }
171 {
return invasionState_; }
174 const Problem* problemPtr_;
175 InvasionState invasionState_;
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Free function to get the local view of a grid cache object.
Invasion state class for the two-phase PNM.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
Definition: discretization/porenetwork/fvelementgeometry.hh:34
Base class for the finite volume geometry for porenetwork models.
Definition: discretization/porenetwork/gridgeometry.hh:489
The flux variables caches for an element.
Definition: porenetwork/2p/elementfluxvariablescache.hh:40
Flux variable caches traits.
Definition: porenetwork/2p/gridfluxvariablescache.hh:41
FVC FluxVariablesCache
Definition: porenetwork/2p/gridfluxvariablescache.hh:43
IS InvasionState
Definition: porenetwork/2p/gridfluxvariablescache.hh:44
P Problem
Definition: porenetwork/2p/gridfluxvariablescache.hh:42
Flux variable caches on a gridview.
Definition: porenetwork/2p/gridfluxvariablescache.hh:59
The grid flux variables cache for the two-phase PNM hodling the invasion state of the throats.
Definition: porenetwork/2p/gridfluxvariablescache.hh:68
const FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx) const
Definition: porenetwork/2p/gridfluxvariablescache.hh:113
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=true)
Definition: porenetwork/2p/gridfluxvariablescache.hh:88
const Problem & problem() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:109
FluxVariablesCache & cache(std::size_t eIdx, std::size_t scvfIdx)
Definition: porenetwork/2p/gridfluxvariablescache.hh:117
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: porenetwork/2p/gridfluxvariablescache.hh:81
InvasionState & invasionState()
Definition: porenetwork/2p/gridfluxvariablescache.hh:123
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: porenetwork/2p/gridfluxvariablescache.hh:75
const InvasionState & invasionState() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:120
PNMTwoPGridFluxVariablesCache(const Problem &problem)
Definition: porenetwork/2p/gridfluxvariablescache.hh:83
The grid flux variables cache for the two-phase PNM hodling the invasion state of the throats.
Definition: porenetwork/2p/gridfluxvariablescache.hh:139
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: porenetwork/2p/gridfluxvariablescache.hh:152
const Problem & problem() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:164
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: porenetwork/2p/gridfluxvariablescache.hh:146
InvasionState & invasionState()
Definition: porenetwork/2p/gridfluxvariablescache.hh:170
const InvasionState & invasionState() const
Definition: porenetwork/2p/gridfluxvariablescache.hh:167
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=true)
Definition: porenetwork/2p/gridfluxvariablescache.hh:159
PNMTwoPGridFluxVariablesCache(const Problem &problem)
Definition: porenetwork/2p/gridfluxvariablescache.hh:154
Element flux variable cache.
Global flux variable cache.