3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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_STAGGERED_GRID_FLUXVARSCACHE_HH
25#define DUMUX_DISCRETIZATION_STAGGERED_GRID_FLUXVARSCACHE_HH
26
27// make the local view function available whenever we use this class
30
32
33namespace Dumux {
34
41template<class P, class FVC, class FVCF, int upwOrder>
43{
44 using Problem = P;
45 using FluxVariablesCache = FVC;
47
48 template<class GridFluxVariablesCache, bool cachingEnabled>
50 static constexpr int upwindSchemeOrder = upwOrder;
51};
52
57template<class Problem,
58 class FluxVariablesCache,
59 class FluxVariablesCacheFiller,
60 bool EnableGridFluxVariablesCache = false,
61 int upwindSchemeOrder = 1,
64
70template<class P, class FVC, class FVCF, int upwindSchemeOrder, class TheTraits>
71class StaggeredGridFluxVariablesCache<P, FVC, FVCF, true, upwindSchemeOrder, TheTraits>
72{
73 using Problem = typename TheTraits::Problem;
75
77 using FluxVariablesCacheFiller = typename TheTraits::FluxVariablesCacheFiller;
78public:
80 using Traits = TheTraits;
81
83 using FluxVariablesCache = typename Traits::FluxVariablesCache;
84 using Scalar = typename FluxVariablesCache::Scalar;
85
86 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
87
89 static constexpr bool cachingEnabled = true;
90
92 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
93
94 [[deprecated("Will be removed after 3.2. Use StaggeredGridFluxVariablesCache(problem) instead.")]]
95 StaggeredGridFluxVariablesCache(const Problem& problem, const std::string& paramGroup)
96 : problemPtr_(&problem)
97 , staggeredUpwindMethods_(paramGroup)
98 {}
99
100 StaggeredGridFluxVariablesCache(const Problem& problem)
101 : problemPtr_(&problem)
102 , staggeredUpwindMethods_(problem.paramGroup())
103 {}
104
105 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
106 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
107 void update(const GridGeometry& gridGeometry,
108 const GridVolumeVariables& gridVolVars,
109 const SolutionVector& sol,
110 bool forceUpdate = false)
111 {
112 // only do the update if fluxes are solution dependent or if update is forced
113 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
114 {
115 // instantiate helper class to fill the caches
116 // FluxVariablesCacheFiller filler(problem()); TODO: use proper ctor
117 FluxVariablesCacheFiller filler(problem());
118
119 fluxVarsCache_.resize(gridGeometry.numScvf());
120 for (const auto& element : elements(gridGeometry.gridView()))
121 {
122 // Prepare the geometries within the elements of the stencil
123 auto fvGeometry = localView(gridGeometry);
124 fvGeometry.bind(element);
125
126 auto elemVolVars = localView(gridVolVars);
127 elemVolVars.bind(element, fvGeometry, sol);
128
129 for (auto&& scvf : scvfs(fvGeometry))
130 {
131 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
132 }
133 }
134 }
135 }
136
139 {
140 return staggeredUpwindMethods_;
141 }
142
143 const Problem& problem() const
144 { return *problemPtr_; }
145
146 // access operators in the case of caching
147 const FluxVariablesCache& operator [](std::size_t scvfIdx) const
148 { return fluxVarsCache_[scvfIdx]; }
149
150 FluxVariablesCache& operator [](std::size_t scvfIdx)
151 { return fluxVarsCache_[scvfIdx]; }
152
153private:
154 const Problem* problemPtr_;
156
157 std::vector<FluxVariablesCache> fluxVarsCache_;
158 std::vector<std::size_t> globalScvfIndices_;
159};
160
166template<class P, class FVC, class FVCF, int upwindSchemeOrder, class TheTraits>
167class StaggeredGridFluxVariablesCache<P, FVC, FVCF, false, upwindSchemeOrder, TheTraits>
168{
169 using Problem = typename TheTraits::Problem;
171
173 using FluxVariablesCacheFiller = typename TheTraits::FluxVariablesCacheFiller;
174public:
176 using Traits = TheTraits;
177
179 using FluxVariablesCache = typename Traits::FluxVariablesCache;
180
182 using Scalar = typename FluxVariablesCache::Scalar;
183
185 static constexpr bool cachingEnabled = false;
186
188 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
189
190 StaggeredGridFluxVariablesCache(const Problem& problem)
191 : problemPtr_(&problem)
192 , staggeredUpwindMethods_(problem.paramGroup())
193 {}
194
195 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
196 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
197 void update(const GridGeometry& gridGeometry,
198 const GridVolumeVariables& gridVolVars,
199 const SolutionVector& sol,
200 bool forceUpdate = false) {}
201
202 const Problem& problem() const
203 { return *problemPtr_; }
204
207 {
208 return staggeredUpwindMethods_;
209 }
210
211private:
212 const Problem* problemPtr_;
214
215};
216
217} // end namespace Dumux
218
219#endif
Free function to get the local view of a grid cache object.
This file contains different higher order methods for approximating the velocity.
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
Base class for the stencil local flux variables cache for the staggered model.
Definition: staggered/elementfluxvariablescache.hh:41
Traits class to be used for the StaggeredGridVFluxVariablesCache.
Definition: staggered/gridfluxvariablescache.hh:43
static constexpr int upwindSchemeOrder
Definition: staggered/gridfluxvariablescache.hh:50
P Problem
Definition: staggered/gridfluxvariablescache.hh:44
FVCF FluxVariablesCacheFiller
Definition: staggered/gridfluxvariablescache.hh:46
FVC FluxVariablesCache
Definition: staggered/gridfluxvariablescache.hh:45
Flux variables cache class for staggered models.
Definition: staggered/gridfluxvariablescache.hh:63
Flux variables cache class for staggered models. Specialization in case of storing the flux cache.
Definition: staggered/gridfluxvariablescache.hh:72
typename FluxVariablesCache::Scalar Scalar
Definition: staggered/gridfluxvariablescache.hh:84
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: staggered/gridfluxvariablescache.hh:107
TheTraits Traits
the flux var cache traits
Definition: staggered/gridfluxvariablescache.hh:80
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: staggered/gridfluxvariablescache.hh:100
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: staggered/gridfluxvariablescache.hh:92
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: staggered/gridfluxvariablescache.hh:83
const StaggeredUpwindMethods< Scalar, upwindSchemeOrder > & staggeredUpwindMethods() const
Return the StaggeredUpwindMethods.
Definition: staggered/gridfluxvariablescache.hh:138
const Problem & problem() const
Definition: staggered/gridfluxvariablescache.hh:143
StaggeredGridFluxVariablesCache(const Problem &problem, const std::string &paramGroup)
Definition: staggered/gridfluxvariablescache.hh:95
Flux variables cache class for staggered models. Specialization in case of not storing the flux cache...
Definition: staggered/gridfluxvariablescache.hh:168
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: staggered/gridfluxvariablescache.hh:179
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: staggered/gridfluxvariablescache.hh:190
TheTraits Traits
the flux var cache traits
Definition: staggered/gridfluxvariablescache.hh:176
const Problem & problem() const
Definition: staggered/gridfluxvariablescache.hh:202
typename FluxVariablesCache::Scalar Scalar
the scalar type
Definition: staggered/gridfluxvariablescache.hh:182
const StaggeredUpwindMethods< Scalar, upwindSchemeOrder > & staggeredUpwindMethods() const
Return the UpwindingMethods.
Definition: staggered/gridfluxvariablescache.hh:206
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: staggered/gridfluxvariablescache.hh:188
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: staggered/gridfluxvariablescache.hh:197
This file contains different higher order methods for approximating the velocity.
Definition: staggeredupwindmethods.hh:62