3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/facecentered/staggered/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_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GRID_FLUXVARSCACHE_HH
26
27// make the local view function available whenever we use this class
30
31namespace Dumux {
32
37template<class P, class FVC, class FVCF>
39{
40 using Problem = P;
41 using FluxVariablesCache = FVC;
43
44 template<class GridFluxVariablesCache, bool cachingEnabled>
46};
47
53template<class Problem,
54 class FluxVariablesCache,
55 class FluxVariablesCacheFiller,
56 bool cachingEnabled = false,
59
65template<class P, class FVC, class FVCF, class Traits>
66class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, true, Traits>
67{
68 using Problem = typename Traits::Problem;
70 using FluxVariablesCacheFiller = typename Traits::FluxVariablesCacheFiller;
71
72public:
74 using FluxVariablesCache = typename Traits::FluxVariablesCache;
75
77 static constexpr bool cachingEnabled = true;
78
80 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
81
82 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
83
84 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
85 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
86 void update(const GridGeometry& gridGeometry,
87 const GridVolumeVariables& gridVolVars,
88 const SolutionVector& sol,
89 bool forceUpdate = false)
90 {
91 // only do the update if fluxes are solution dependent or if update is forced
92 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
93 {
94 // instantiate helper class to fill the caches
95 FluxVariablesCacheFiller filler(problem());
96
97 fluxVarsCache_.resize(gridGeometry.numScvf());
98 for (const auto& element : elements(gridGeometry.gridView()))
99 {
100 // Prepare the geometries within the elements of the stencil
101 auto fvGeometry = localView(gridGeometry);
102 fvGeometry.bind(element);
103
104 auto elemVolVars = localView(gridVolVars);
105 elemVolVars.bind(element, fvGeometry, sol);
106
107 for (auto&& scvf : scvfs(fvGeometry))
108 {
109 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
110 }
111 }
112 }
113 }
114
115 const Problem& problem() const
116 { return *problemPtr_; }
117
118 template<class SubControlVolumeFace>
119 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
120 { return fluxVarsCache_[scvf.index()]; }
121
122 template<class SubControlVolumeFace>
123 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
124 { return fluxVarsCache_[scvf.index()]; }
125
126private:
127 // currently bound element
128 const Problem* problemPtr_;
129 std::vector<FluxVariablesCache> fluxVarsCache_;
130};
131
136template<class P, class FVC, class FVCF, class Traits>
137class FaceCenteredStaggeredGridFluxVariablesCache<P, FVC, FVCF, false, Traits>
138{
139 using Problem = typename Traits::Problem;
141
142public:
144 using FluxVariablesCache = typename Traits::FluxVariablesCache;
145
147 static constexpr bool cachingEnabled = false;
148
150 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
151
152 FaceCenteredStaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
153
154 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
155 void update(const GridGeometry& gridGeometry,
156 const GridVolumeVariables& gridVolVars,
157 const SolutionVector& sol,
158 bool forceUpdate = false) {}
159
160 const Problem& problem() const
161 { return *problemPtr_; }
162
163private:
164 const Problem* problemPtr_;
165};
166
167} // end namespace Dumux
168
169#endif
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
Definition: adapt.hh:29
The flux variables caches for an element.
Definition: discretization/facecentered/staggered/elementfluxvariablescache.hh:42
Flux variable caches traits.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:39
FVCF FluxVariablesCacheFiller
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:42
P Problem
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:40
FVC FluxVariablesCache
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:41
Flux variable caches on a gridview.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:58
Flux variable caches on a gridview with grid caching enabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:67
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:74
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:80
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:86
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:115
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:82
Flux variable caches on a gridview with grid caching disabled.
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:138
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:144
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:155
const Problem & problem() const
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:160
FaceCenteredStaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:152
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/facecentered/staggered/gridfluxvariablescache.hh:150
Global flux variable cache.