Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup FaceCenteredStaggeredDiscretization | ||
10 | * \brief Global flux variable cache | ||
11 | */ | ||
12 | #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_ELEMENT_FLUXVARSCACHE_HH | ||
13 | #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_ELEMENT_FLUXVARSCACHE_HH | ||
14 | |||
15 | #include <cstddef> | ||
16 | #include <vector> | ||
17 | #include <utility> | ||
18 | |||
19 | namespace Dumux { | ||
20 | |||
21 | /*! | ||
22 | * \ingroup FaceCenteredStaggeredDiscretization | ||
23 | * \brief The flux variables caches for an element | ||
24 | * \note The class is specialized for a version with and without caching | ||
25 | * If grid caching is enabled the flux caches are stored for the whole gridview in the corresponding | ||
26 | * GridFluxVariablesCache which is memory intensive but faster. For caching disabled the | ||
27 | * flux caches are locally computed for each element whenever needed. | ||
28 | */ | ||
29 | template<class GFVC, bool cachingEnabled> | ||
30 | class FaceCenteredStaggeredElementFluxVariablesCache; | ||
31 | |||
32 | /*! | ||
33 | * \ingroup FaceCenteredStaggeredDiscretization | ||
34 | * \brief The flux variables caches for an element with caching enabled | ||
35 | */ | ||
36 | template<class GFVC> | ||
37 | class FaceCenteredStaggeredElementFluxVariablesCache<GFVC, true> | ||
38 | { | ||
39 | public: | ||
40 | //! export the type of the grid flux variables cache | ||
41 | using GridFluxVariablesCache = GFVC; | ||
42 | |||
43 | //! export the type of the flux variables cache | ||
44 | using FluxVariablesCache = typename GFVC::FluxVariablesCache; | ||
45 | |||
46 | FaceCenteredStaggeredElementFluxVariablesCache(const GridFluxVariablesCache& global) | ||
47 | : gridFluxVarsCachePtr_(&global) {} | ||
48 | |||
49 | /*! | ||
50 | * \brief bind the local view (r-value overload) | ||
51 | * This overload is called when an instance of this class is a temporary in the usage context | ||
52 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
53 | */ | ||
54 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
55 | FaceCenteredStaggeredElementFluxVariablesCache bind(const typename FVElementGeometry::Element& element, | ||
56 | const FVElementGeometry& fvGeometry, | ||
57 | const ElementVolumeVariables& elemVolVars) && | ||
58 | { | ||
59 | this->bind(element, fvGeometry, elemVolVars); | ||
60 | return std::move(*this); | ||
61 | } | ||
62 | |||
63 | // Function is called by the BoxLocalJacobian prior to flux calculations on the element. | ||
64 | // We assume the FVGeometries to be bound at this point | ||
65 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
66 | ✗ | void bind(const typename FVElementGeometry::Element& element, | |
67 | const FVElementGeometry& fvGeometry, | ||
68 | const ElementVolumeVariables& elemVolVars) & | ||
69 | { | ||
70 | 2574802 | bindElement(element, fvGeometry, elemVolVars); | |
71 | ✗ | } | |
72 | |||
73 | /*! | ||
74 | * \brief bind the local view (r-value overload) | ||
75 | * This overload is called when an instance of this class is a temporary in the usage context | ||
76 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
77 | */ | ||
78 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
79 | FaceCenteredStaggeredElementFluxVariablesCache bindElement(const typename FVElementGeometry::Element& element, | ||
80 | const FVElementGeometry& fvGeometry, | ||
81 | const ElementVolumeVariables& elemVolVars) && | ||
82 | { | ||
83 | this->bindElement(element, fvGeometry, elemVolVars); | ||
84 | return std::move(*this); | ||
85 | } | ||
86 | |||
87 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
88 | ✗ | void bindElement(const typename FVElementGeometry::Element& element, | |
89 | const FVElementGeometry& fvGeometry, | ||
90 | const ElementVolumeVariables& elemVolVars) & | ||
91 | { | ||
92 | ✗ | eIdx_ = fvGeometry.gridGeometry().elementMapper().index(element); | |
93 | ✗ | } | |
94 | |||
95 | /*! | ||
96 | * \brief bind the local view (r-value overload) | ||
97 | * This overload is called when an instance of this class is a temporary in the usage context | ||
98 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
99 | */ | ||
100 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
101 | FaceCenteredStaggeredElementFluxVariablesCache bindScvf(const typename FVElementGeometry::Element& element, | ||
102 | const FVElementGeometry& fvGeometry, | ||
103 | const ElementVolumeVariables& elemVolVars, | ||
104 | const typename FVElementGeometry::SubControlVolumeFace& scvf) && | ||
105 | { | ||
106 | this->bindScvf(element, fvGeometry, elemVolVars, scvf); | ||
107 | return std::move(*this); | ||
108 | } | ||
109 | |||
110 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
111 | void bindScvf(const typename FVElementGeometry::Element& element, | ||
112 | const FVElementGeometry& fvGeometry, | ||
113 | const ElementVolumeVariables& elemVolVars, | ||
114 | const typename FVElementGeometry::SubControlVolumeFace& scvf) & | ||
115 | { | ||
116 | bindElement(element, fvGeometry, elemVolVars); | ||
117 | } | ||
118 | |||
119 | // access operator | ||
120 | template<class SubControlVolumeFace> | ||
121 | const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const | ||
122 | { return gridFluxVarsCache()[scvf]; } | ||
123 | |||
124 | //! The global object we are a restriction of | ||
125 | const GridFluxVariablesCache& gridFluxVarsCache() const | ||
126 | { return *gridFluxVarsCachePtr_; } | ||
127 | |||
128 | private: | ||
129 | const GridFluxVariablesCache* gridFluxVarsCachePtr_; | ||
130 | std::size_t eIdx_; //!< currently bound element | ||
131 | }; | ||
132 | |||
133 | /*! | ||
134 | * \ingroup FaceCenteredStaggeredDiscretization | ||
135 | * \brief The flux variables caches for an element with caching disabled | ||
136 | */ | ||
137 | template<class GFVC> | ||
138 |
2/6✓ Branch 1 taken 31036 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31036 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
62072 | class FaceCenteredStaggeredElementFluxVariablesCache<GFVC, false> |
139 | { | ||
140 | public: | ||
141 | //! export the type of the grid flux variables cache | ||
142 | using GridFluxVariablesCache = GFVC; | ||
143 | |||
144 | //! export the type of the flux variables cache | ||
145 | using FluxVariablesCache = typename GFVC::FluxVariablesCache; | ||
146 | |||
147 | FaceCenteredStaggeredElementFluxVariablesCache(const GridFluxVariablesCache& global) | ||
148 | 62072 | : gridFluxVarsCachePtr_(&global) {} | |
149 | |||
150 | /*! | ||
151 | * \brief bind the local view (r-value overload) | ||
152 | * This overload is called when an instance of this class is a temporary in the usage context | ||
153 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
154 | */ | ||
155 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
156 | FaceCenteredStaggeredElementFluxVariablesCache bind(const typename FVElementGeometry::Element& element, | ||
157 | const FVElementGeometry& fvGeometry, | ||
158 | const ElementVolumeVariables& elemVolVars) && | ||
159 | { | ||
160 | this->bind(element, fvGeometry, elemVolVars); | ||
161 | return std::move(*this); | ||
162 | } | ||
163 | |||
164 | // Function is called by the BoxLocalJacobian prior to flux calculations on the element. | ||
165 | // We assume the FVGeometries to be bound at this point | ||
166 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
167 | ✗ | void bind(const typename FVElementGeometry::Element& element, | |
168 | const FVElementGeometry& fvGeometry, | ||
169 | const ElementVolumeVariables& elemVolVars) & | ||
170 | { | ||
171 | 31036 | bindElement(element, fvGeometry, elemVolVars); | |
172 | ✗ | } | |
173 | |||
174 | /*! | ||
175 | * \brief bind the local view (r-value overload) | ||
176 | * This overload is called when an instance of this class is a temporary in the usage context | ||
177 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
178 | */ | ||
179 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
180 | FaceCenteredStaggeredElementFluxVariablesCache bindElement(const typename FVElementGeometry::Element& element, | ||
181 | const FVElementGeometry& fvGeometry, | ||
182 | const ElementVolumeVariables& elemVolVars) && | ||
183 | { | ||
184 | this->bindElement(element, fvGeometry, elemVolVars); | ||
185 | return std::move(*this); | ||
186 | } | ||
187 | |||
188 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
189 | ✗ | void bindElement(const typename FVElementGeometry::Element& element, | |
190 | const FVElementGeometry& fvGeometry, | ||
191 | const ElementVolumeVariables& elemVolVars) & | ||
192 | { | ||
193 | // temporary resizing of the cache | ||
194 | ✗ | fluxVarsCache_.resize(fvGeometry.numScvf()); | |
195 | // for (auto&& scvf : scvfs(fvGeometry)) | ||
196 | // (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf); TODO | ||
197 | ✗ | } | |
198 | |||
199 | /*! | ||
200 | * \brief bind the local view (r-value overload) | ||
201 | * This overload is called when an instance of this class is a temporary in the usage context | ||
202 | * This allows a usage like this: `const auto view = localView(...).bind(element);` | ||
203 | */ | ||
204 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
205 | FaceCenteredStaggeredElementFluxVariablesCache bindScvf(const typename FVElementGeometry::Element& element, | ||
206 | const FVElementGeometry& fvGeometry, | ||
207 | const ElementVolumeVariables& elemVolVars, | ||
208 | const typename FVElementGeometry::SubControlVolumeFace& scvf) && | ||
209 | { | ||
210 | this->bindScvf(element, fvGeometry, elemVolVars, scvf); | ||
211 | return std::move(*this); | ||
212 | } | ||
213 | |||
214 | template<class FVElementGeometry, class ElementVolumeVariables> | ||
215 | void bindScvf(const typename FVElementGeometry::Element& element, | ||
216 | const FVElementGeometry& fvGeometry, | ||
217 | const ElementVolumeVariables& elemVolVars, | ||
218 | const typename FVElementGeometry::SubControlVolumeFace& scvf) & | ||
219 | { | ||
220 | fluxVarsCache_.resize(fvGeometry.numScvf()); | ||
221 | // (*this)[scvf].update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf); TODO | ||
222 | } | ||
223 | |||
224 | // access operator | ||
225 | template<class SubControlVolumeFace> | ||
226 | const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const | ||
227 | { return fluxVarsCache_[scvf.index()]; } | ||
228 | |||
229 | // access operator | ||
230 | template<class SubControlVolumeFace> | ||
231 | FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) | ||
232 | { return fluxVarsCache_[scvf.index()]; } | ||
233 | |||
234 | //! The global object we are a restriction of | ||
235 | const GridFluxVariablesCache& gridFluxVarsCache() const | ||
236 | { return *gridFluxVarsCachePtr_; } | ||
237 | |||
238 | private: | ||
239 | const GridFluxVariablesCache* gridFluxVarsCachePtr_; | ||
240 | std::vector<FluxVariablesCache> fluxVarsCache_; | ||
241 | }; | ||
242 | |||
243 | } // end namespace Dumux | ||
244 | |||
245 | #endif | ||
246 |