3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porenetwork/2p/gridfluxvariablescache.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
25#define DUMUX_PNM_2P_GRID_FLUXVARSCACHE_HH
26
31#include "invasionstate.hh"
32
33namespace Dumux::PoreNetwork {
34
39template<class P, class FVC, class IS = TwoPInvasionState<P>>
41{
42 using Problem = P;
43 using FluxVariablesCache = FVC;
44 using InvasionState = IS;
45
46 template<class GridFluxVariablesCache, bool cachingEnabled>
48};
49
55template<class Problem,
56 class FluxVariablesCache,
57 bool cachingEnabled,
58 class Traits>
60
66template<class P, class FVC, class Traits>
67class PNMTwoPGridFluxVariablesCache<P, FVC, true, Traits>
68{
69 using Problem = typename Traits::Problem;
71 using InvasionState = typename Traits::InvasionState;
72
73public:
75 using FluxVariablesCache = typename Traits::FluxVariablesCache;
76
78 static constexpr bool cachingEnabled = true;
79
81 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
82
83 PNMTwoPGridFluxVariablesCache(const Problem& problem)
84 : problemPtr_(&problem)
85 , invasionState_(problem) {}
86
87 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
88 void update(const GridGeometry& gridGeometry,
89 const GridVolumeVariables& gridVolVars,
90 const SolutionVector& sol,
91 bool forceUpdate = true)
92 {
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()))
97 {
98 auto eIdx = gridGeometry.elementMapper().index(element);
99
100 // bind the geometries and volume variables to the element (all the elements in stencil)
101 fvGeometry.bind(element);
102 elemVolVars.bind(element, fvGeometry, sol);
103
104 for (auto&& scvf : scvfs(fvGeometry))
105 cache(eIdx, scvf.index()).update(problem(), element, fvGeometry, elemVolVars, scvf, invasionState().invaded(element));
106 }
107 }
108
109 const Problem& problem() const
110 { return *problemPtr_; }
111
112 // access operator
113 const FluxVariablesCache& cache(std::size_t eIdx, [[maybe_unused]] std::size_t scvfIdx) const
114 { return fluxVarsCache_[eIdx]; }
115
116 // access operator
117 FluxVariablesCache& cache(std::size_t eIdx, [[maybe_unused]] std::size_t scvfIdx)
118 { return fluxVarsCache_[eIdx]; }
119
120 const InvasionState& invasionState() const
121 { return invasionState_; }
122
123 InvasionState& invasionState()
124 { return invasionState_; }
125
126private:
127 const Problem* problemPtr_;
128 std::vector<FluxVariablesCache> fluxVarsCache_;
129 InvasionState invasionState_;
130};
131
137template<class P, class FVC, class Traits>
138class PNMTwoPGridFluxVariablesCache<P, FVC, false, Traits>
139{
140 using Problem = typename Traits::Problem;
142 using InvasionState = typename Traits::InvasionState;
143
144 public:
146 using FluxVariablesCache = typename Traits::FluxVariablesCache;
147
149 static constexpr bool cachingEnabled = false;
150
152 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
153
154 PNMTwoPGridFluxVariablesCache(const Problem& problem)
155 : problemPtr_(&problem)
156 , invasionState_(problem) {}
157
158 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
159 void update(const GridGeometry& gridGeometry,
160 const GridVolumeVariables& gridVolVars,
161 const SolutionVector& sol,
162 bool forceUpdate = true) {}
163
164 const Problem& problem() const
165 { return *problemPtr_; }
166
167 const InvasionState& invasionState() const
168 { return invasionState_; }
169
170 InvasionState& invasionState()
171 { return invasionState_; }
172
173private:
174 const Problem* problemPtr_;
175 InvasionState invasionState_;
176};
177} // end namespace Dumux::PoreNetwork
178
179#endif
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.