3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/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
90
92 static constexpr bool cachingEnabled = true;
93
95 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
96
97 StaggeredGridFluxVariablesCache(const Problem& problem)
98 : problemPtr_(&problem)
99 , staggeredUpwindMethods_(problem.paramGroup())
100 {}
101
102 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
103 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
104 void update(const GridGeometry& gridGeometry,
105 const GridVolumeVariables& gridVolVars,
106 const SolutionVector& sol,
107 bool forceUpdate = false)
108 {
109 // only do the update if fluxes are solution dependent or if update is forced
110 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
111 {
112 // instantiate helper class to fill the caches
113 // FluxVariablesCacheFiller filler(problem()); TODO: use proper ctor
114 FluxVariablesCacheFiller filler(problem());
115
116 fluxVarsCache_.resize(gridGeometry.numScvf());
117 auto fvGeometry = localView(gridGeometry);
118 auto elemVolVars = localView(gridVolVars);
119 for (const auto& element : elements(gridGeometry.gridView()))
120 {
121 // Prepare the geometries within the elements of the stencil
122 fvGeometry.bind(element);
123 elemVolVars.bind(element, fvGeometry, sol);
124
125 for (auto&& scvf : scvfs(fvGeometry))
126 {
127 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
128 }
129 }
130 }
131 }
132
135 {
136 return staggeredUpwindMethods_;
137 }
138
139 const Problem& problem() const
140 { return *problemPtr_; }
141
142 // access operators in the case of caching
143 const FluxVariablesCache& operator [](std::size_t scvfIdx) const
144 { return fluxVarsCache_[scvfIdx]; }
145
146 FluxVariablesCache& operator [](std::size_t scvfIdx)
147 { return fluxVarsCache_[scvfIdx]; }
148
149private:
150 const Problem* problemPtr_;
151 UpwindScheme staggeredUpwindMethods_;
152
153 std::vector<FluxVariablesCache> fluxVarsCache_;
154 std::vector<std::size_t> globalScvfIndices_;
155};
156
162template<class P, class FVC, class FVCF, int upwindSchemeOrder, class TheTraits>
163class StaggeredGridFluxVariablesCache<P, FVC, FVCF, false, upwindSchemeOrder, TheTraits>
164{
165 using Problem = typename TheTraits::Problem;
167
169 using FluxVariablesCacheFiller = typename TheTraits::FluxVariablesCacheFiller;
170public:
172 using Traits = TheTraits;
173
175 using FluxVariablesCache = typename Traits::FluxVariablesCache;
176
178 using Scalar = typename FluxVariablesCache::Scalar;
179
181 static constexpr bool cachingEnabled = false;
182
184 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
185
188
189 StaggeredGridFluxVariablesCache(const Problem& problem)
190 : problemPtr_(&problem)
191 , staggeredUpwindMethods_(problem.paramGroup())
192 {}
193
194 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
195 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
196 void update(const GridGeometry& gridGeometry,
197 const GridVolumeVariables& gridVolVars,
198 const SolutionVector& sol,
199 bool forceUpdate = false) {}
200
201 const Problem& problem() const
202 { return *problemPtr_; }
203
206 {
207 return staggeredUpwindMethods_;
208 }
209
210private:
211 const Problem* problemPtr_;
212 UpwindScheme staggeredUpwindMethods_;
213};
214
215} // end namespace Dumux
216
217#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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Base class for the stencil local flux variables cache for the staggered model.
Definition: discretization/staggered/elementfluxvariablescache.hh:42
Traits class to be used for the StaggeredGridVFluxVariablesCache.
Definition: discretization/staggered/gridfluxvariablescache.hh:43
static constexpr int upwindSchemeOrder
Definition: discretization/staggered/gridfluxvariablescache.hh:50
P Problem
Definition: discretization/staggered/gridfluxvariablescache.hh:44
FVCF FluxVariablesCacheFiller
Definition: discretization/staggered/gridfluxvariablescache.hh:46
FVC FluxVariablesCache
Definition: discretization/staggered/gridfluxvariablescache.hh:45
Flux variables cache class for staggered models.
Definition: discretization/staggered/gridfluxvariablescache.hh:63
Flux variables cache class for staggered models. Specialization in case of storing the flux cache.
Definition: discretization/staggered/gridfluxvariablescache.hh:72
typename FluxVariablesCache::Scalar Scalar
Definition: discretization/staggered/gridfluxvariablescache.hh:84
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/staggered/gridfluxvariablescache.hh:104
TheTraits Traits
the flux var cache traits
Definition: discretization/staggered/gridfluxvariablescache.hh:80
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/staggered/gridfluxvariablescache.hh:97
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/staggered/gridfluxvariablescache.hh:95
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/staggered/gridfluxvariablescache.hh:83
const UpwindScheme & staggeredUpwindMethods() const
Return the StaggeredUpwindMethods.
Definition: discretization/staggered/gridfluxvariablescache.hh:134
const Problem & problem() const
Definition: discretization/staggered/gridfluxvariablescache.hh:139
Flux variables cache class for staggered models. Specialization in case of not storing the flux cache...
Definition: discretization/staggered/gridfluxvariablescache.hh:164
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/staggered/gridfluxvariablescache.hh:175
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/staggered/gridfluxvariablescache.hh:189
TheTraits Traits
the flux var cache traits
Definition: discretization/staggered/gridfluxvariablescache.hh:172
const Problem & problem() const
Definition: discretization/staggered/gridfluxvariablescache.hh:201
typename FluxVariablesCache::Scalar Scalar
the scalar type
Definition: discretization/staggered/gridfluxvariablescache.hh:178
const UpwindScheme & staggeredUpwindMethods() const
Return the UpwindingMethods.
Definition: discretization/staggered/gridfluxvariablescache.hh:205
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/staggered/gridfluxvariablescache.hh:184
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/staggered/gridfluxvariablescache.hh:196
Forward declaration of the upwind scheme implementation.
Definition: flux/upwindscheme.hh:34
This file contains different higher order methods for approximating the velocity.
Definition: staggeredupwindmethods.hh:62