version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_STAGGERED_GRID_FLUXVARSCACHE_HH
13#define DUMUX_DISCRETIZATION_STAGGERED_GRID_FLUXVARSCACHE_HH
14
15// make the local view function available whenever we use this class
18
20
21namespace Dumux {
22
29template<class P, class FVC, class FVCF, int upwOrder>
31{
32 using Problem = P;
33 using FluxVariablesCache = FVC;
35
36 template<class GridFluxVariablesCache, bool cachingEnabled>
38 static constexpr int upwindSchemeOrder = upwOrder;
39};
40
45template<class Problem,
46 class FluxVariablesCache,
47 class FluxVariablesCacheFiller,
48 bool EnableGridFluxVariablesCache = false,
49 int upwindSchemeOrder = 1,
52
58template<class P, class FVC, class FVCF, int upwindSchemeOrder, class TheTraits>
59class StaggeredGridFluxVariablesCache<P, FVC, FVCF, true, upwindSchemeOrder, TheTraits>
60{
61 using Problem = typename TheTraits::Problem;
63
65 using FluxVariablesCacheFiller = typename TheTraits::FluxVariablesCacheFiller;
66public:
68 using Traits = TheTraits;
69
71 using FluxVariablesCache = typename Traits::FluxVariablesCache;
72 using Scalar = typename FluxVariablesCache::Scalar;
73
74 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
75
78
80 static constexpr bool cachingEnabled = true;
81
83 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
84
85 StaggeredGridFluxVariablesCache(const Problem& problem)
86 : problemPtr_(&problem)
87 , staggeredUpwindMethods_(problem.paramGroup())
88 {}
89
90 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
91 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
92 void update(const GridGeometry& gridGeometry,
93 const GridVolumeVariables& gridVolVars,
94 const SolutionVector& sol,
95 bool forceUpdate = false)
96 {
97 // only do the update if fluxes are solution dependent or if update is forced
98 if (FluxVariablesCacheFiller::isSolDependent || forceUpdate)
99 {
100 // instantiate helper class to fill the caches
101 // FluxVariablesCacheFiller filler(problem()); TODO: use proper ctor
102 FluxVariablesCacheFiller filler(problem());
103
104 fluxVarsCache_.resize(gridGeometry.numScvf());
105 auto fvGeometry = localView(gridGeometry);
106 auto elemVolVars = localView(gridVolVars);
107 for (const auto& element : elements(gridGeometry.gridView()))
108 {
109 // Prepare the geometries within the elements of the stencil
110 fvGeometry.bind(element);
111 elemVolVars.bind(element, fvGeometry, sol);
112
113 for (auto&& scvf : scvfs(fvGeometry))
114 {
115 filler.fill(*this, fluxVarsCache_[scvf.index()], element, fvGeometry, elemVolVars, scvf, forceUpdate);
116 }
117 }
118 }
119 }
120
123 {
124 return staggeredUpwindMethods_;
125 }
126
127 const Problem& problem() const
128 { return *problemPtr_; }
129
130 // access operators in the case of caching
131 const FluxVariablesCache& operator [](std::size_t scvfIdx) const
132 { return fluxVarsCache_[scvfIdx]; }
133
134 FluxVariablesCache& operator [](std::size_t scvfIdx)
135 { return fluxVarsCache_[scvfIdx]; }
136
137private:
138 const Problem* problemPtr_;
139 UpwindScheme staggeredUpwindMethods_;
140
141 std::vector<FluxVariablesCache> fluxVarsCache_;
142 std::vector<std::size_t> globalScvfIndices_;
143};
144
150template<class P, class FVC, class FVCF, int upwindSchemeOrder, class TheTraits>
151class StaggeredGridFluxVariablesCache<P, FVC, FVCF, false, upwindSchemeOrder, TheTraits>
152{
153 using Problem = typename TheTraits::Problem;
155
157 using FluxVariablesCacheFiller = typename TheTraits::FluxVariablesCacheFiller;
158public:
160 using Traits = TheTraits;
161
163 using FluxVariablesCache = typename Traits::FluxVariablesCache;
164
166 using Scalar = typename FluxVariablesCache::Scalar;
167
169 static constexpr bool cachingEnabled = false;
170
172 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
173
176
177 StaggeredGridFluxVariablesCache(const Problem& problem)
178 : problemPtr_(&problem)
179 , staggeredUpwindMethods_(problem.paramGroup())
180 {}
181
182 // When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
183 template<class GridGeometry, class GridVolumeVariables, class SolutionVector>
184 void update(const GridGeometry& gridGeometry,
185 const GridVolumeVariables& gridVolVars,
186 const SolutionVector& sol,
187 bool forceUpdate = false) {}
188
189 const Problem& problem() const
190 { return *problemPtr_; }
191
194 {
195 return staggeredUpwindMethods_;
196 }
197
198private:
199 const Problem* problemPtr_;
200 UpwindScheme staggeredUpwindMethods_;
201};
202
203} // end namespace Dumux
204
205#endif
Base class for the stencil local flux variables cache for the staggered model.
Definition: discretization/staggered/elementfluxvariablescache.hh:30
Flux variables cache class for staggered models. Specialization in case of not storing the flux cache...
Definition: discretization/staggered/gridfluxvariablescache.hh:152
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/staggered/gridfluxvariablescache.hh:163
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/staggered/gridfluxvariablescache.hh:177
TheTraits Traits
the flux var cache traits
Definition: discretization/staggered/gridfluxvariablescache.hh:160
const Problem & problem() const
Definition: discretization/staggered/gridfluxvariablescache.hh:189
typename FluxVariablesCache::Scalar Scalar
the scalar type
Definition: discretization/staggered/gridfluxvariablescache.hh:166
const UpwindScheme & staggeredUpwindMethods() const
Return the UpwindingMethods.
Definition: discretization/staggered/gridfluxvariablescache.hh:193
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/staggered/gridfluxvariablescache.hh:172
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/staggered/gridfluxvariablescache.hh:184
Flux variables cache class for staggered models. Specialization in case of storing the flux cache.
Definition: discretization/staggered/gridfluxvariablescache.hh:60
typename FluxVariablesCache::Scalar Scalar
Definition: discretization/staggered/gridfluxvariablescache.hh:72
void update(const GridGeometry &gridGeometry, const GridVolumeVariables &gridVolVars, const SolutionVector &sol, bool forceUpdate=false)
Definition: discretization/staggered/gridfluxvariablescache.hh:92
TheTraits Traits
the flux var cache traits
Definition: discretization/staggered/gridfluxvariablescache.hh:68
StaggeredGridFluxVariablesCache(const Problem &problem)
Definition: discretization/staggered/gridfluxvariablescache.hh:85
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: discretization/staggered/gridfluxvariablescache.hh:83
typename Traits::FluxVariablesCache FluxVariablesCache
export the flux variable cache type
Definition: discretization/staggered/gridfluxvariablescache.hh:71
const UpwindScheme & staggeredUpwindMethods() const
Return the StaggeredUpwindMethods.
Definition: discretization/staggered/gridfluxvariablescache.hh:122
const Problem & problem() const
Definition: discretization/staggered/gridfluxvariablescache.hh:127
Flux variables cache class for staggered models.
Definition: discretization/staggered/gridfluxvariablescache.hh:51
This file contains different higher order methods for approximating the velocity.
Definition: staggeredupwindmethods.hh:50
Forward declaration of the upwind scheme implementation.
Definition: flux/upwindscheme.hh:22
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Free function to get the local view of a grid cache object.
Definition: adapt.hh:17
This file contains different higher order methods for approximating the velocity.
Traits class to be used for the StaggeredGridVFluxVariablesCache.
Definition: discretization/staggered/gridfluxvariablescache.hh:31
static constexpr int upwindSchemeOrder
Definition: discretization/staggered/gridfluxvariablescache.hh:38
P Problem
Definition: discretization/staggered/gridfluxvariablescache.hh:32
FVCF FluxVariablesCacheFiller
Definition: discretization/staggered/gridfluxvariablescache.hh:34
FVC FluxVariablesCache
Definition: discretization/staggered/gridfluxvariablescache.hh:33