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 StaggeredDiscretization | ||
10 | * \copydoc Dumux::StaggeredGridVariables | ||
11 | */ | ||
12 | #ifndef DUMUX_STAGGERED_GRID_VARIABLES_HH | ||
13 | #define DUMUX_STAGGERED_GRID_VARIABLES_HH | ||
14 | |||
15 | #include <dumux/discretization/fvgridvariables.hh> | ||
16 | |||
17 | namespace Dumux { | ||
18 | |||
19 | /*! | ||
20 | * \ingroup StaggeredDiscretization | ||
21 | * \brief Base class for cell center of face specific auxiliary GridVariables classes. | ||
22 | * Provides a common interface and a pointer to the actual grid variables. | ||
23 | */ | ||
24 | template<class ActualGridVariables> | ||
25 | class StaggeredGridVariablesView | ||
26 | { | ||
27 | public: | ||
28 | using GridVolumeVariables = typename ActualGridVariables::GridVolumeVariables; | ||
29 | using GridFaceVariables = typename ActualGridVariables::GridFaceVariables; | ||
30 | using GridFluxVariablesCache = typename ActualGridVariables::GridFluxVariablesCache; | ||
31 | |||
32 | //! export type of the volume variables | ||
33 | using VolumeVariables = typename GridVolumeVariables::VolumeVariables; | ||
34 | |||
35 | //! export primary variable type | ||
36 | using PrimaryVariables = typename VolumeVariables::PrimaryVariables; | ||
37 | using GridGeometry = typename ActualGridVariables::GridGeometry; | ||
38 | |||
39 | 100 | explicit StaggeredGridVariablesView(ActualGridVariables* gridVariables) | |
40 | 100 | : gridVariables_(gridVariables) {} | |
41 | |||
42 | //! return the flux variables cache | ||
43 | ✗ | const GridFluxVariablesCache& gridFluxVarsCache() const | |
44 |
4/8✓ Branch 1 taken 1355444 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1355444 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1355444 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1355444 times.
✗ Branch 11 not taken.
|
5421776 | { return gridVariables_->gridFluxVarsCache(); } |
45 | |||
46 | //! return the flux variables cache | ||
47 | ✗ | GridFluxVariablesCache& gridFluxVarsCache() | |
48 | 11068 | { return gridVariables_->gridFluxVarsCache(); } | |
49 | |||
50 | //! return the current volume variables | ||
51 | ✗ | const GridVolumeVariables& curGridVolVars() const | |
52 |
4/8✓ Branch 1 taken 1355444 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1355444 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1355444 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1355444 times.
✗ Branch 11 not taken.
|
5421776 | { return gridVariables_->curGridVolVars(); } |
53 | |||
54 | //! return the current volume variables | ||
55 | ✗ | GridVolumeVariables& curGridVolVars() | |
56 | 44292116 | { return gridVariables_->curGridVolVars(); } | |
57 | |||
58 | //! return the volume variables of the previous time step (for instationary problems) | ||
59 | ✗ | const GridVolumeVariables& prevGridVolVars() const | |
60 |
4/8✓ Branch 1 taken 1355444 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1355444 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1355444 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1355444 times.
✗ Branch 11 not taken.
|
5421776 | { return gridVariables_->prevGridVolVars(); } |
61 | |||
62 | //! return the volume variables of the previous time step (for instationary problems) | ||
63 | ✗ | GridVolumeVariables& prevGridVolVars() | |
64 | 30 | { return gridVariables_->prevGridVolVars(); } | |
65 | |||
66 | //! return the current face variables | ||
67 | ✗ | const GridFaceVariables& curGridFaceVars() const | |
68 | 5421776 | { return gridVariables_->curGridFaceVars(); } | |
69 | |||
70 | //! return the previous face variables | ||
71 | ✗ | const GridFaceVariables& prevGridFaceVars() const | |
72 | 5421776 | { return gridVariables_->prevGridFaceVars(); } | |
73 | |||
74 | //! return the current face variables | ||
75 | ✗ | GridFaceVariables& curGridFaceVars() | |
76 | 96175728 | { return gridVariables_->curGridFaceVars(); } | |
77 | |||
78 | //! return the previous face variables | ||
79 | ✗ | GridFaceVariables& prevGridFaceVars() | |
80 | ✗ | { return gridVariables_->prevGridFaceVars(); } | |
81 | |||
82 | //! return the fv grid geometry | ||
83 | ✗ | const GridGeometry& gridGeometry() const | |
84 | 22106 | { return (*gridVariables_->gridGeometry_); } | |
85 | |||
86 | // return the actual grid variables | ||
87 | const ActualGridVariables& gridVariables() const | ||
88 | { return *gridVariables_; } | ||
89 | |||
90 | // return the actual grid variables | ||
91 | ActualGridVariables& gridVariables() | ||
92 | { return *gridVariables_; } | ||
93 | |||
94 | protected: | ||
95 | ActualGridVariables* gridVariables_; | ||
96 | }; | ||
97 | |||
98 | /*! | ||
99 | * \ingroup StaggeredDiscretization | ||
100 | * \brief Cell center specific auxiliary GridVariables classes. | ||
101 | * Required for the Dumux multi-domain framework. | ||
102 | */ | ||
103 | template<class ActualGridVariables> | ||
104 | class CellCenterGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables> | ||
105 | { | ||
106 | using ParentType = StaggeredGridVariablesView<ActualGridVariables>; | ||
107 | public: | ||
108 |
1/2✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
|
50 | using ParentType::ParentType; |
109 | |||
110 | //! initialize all variables (stationary case) | ||
111 | template<class SolVector> | ||
112 | void init(const SolVector& curSol) | ||
113 | { | ||
114 | this->curGridVolVars().update(this->gridGeometry(), curSol); | ||
115 | this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol, true); | ||
116 | this->prevGridVolVars().update(this->gridGeometry(), curSol); | ||
117 | } | ||
118 | |||
119 | //! update the volume variables and the flux variables cache | ||
120 | template<class SolVector> | ||
121 | 5519 | void update(const SolVector& curSol) | |
122 | { | ||
123 | 16557 | this->curGridVolVars().update(this->gridGeometry(), curSol); | |
124 | 22076 | this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol); | |
125 | 5519 | } | |
126 | |||
127 | //! resets state to the one before time integration | ||
128 | template<class SolVector> | ||
129 | 15 | void resetTimeStep(const SolVector& sol) | |
130 | { | ||
131 | 45 | this->curGridVolVars() = this->prevGridVolVars(); | |
132 | 60 | this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), sol); | |
133 | 15 | } | |
134 | }; | ||
135 | |||
136 | /*! | ||
137 | * \ingroup StaggeredDiscretization | ||
138 | * \brief Face specific auxiliary GridVariables classes. | ||
139 | * Required for the Dumux multi-domain framework. | ||
140 | */ | ||
141 | template<class ActualGridVariables> | ||
142 | class FaceGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables> | ||
143 | { | ||
144 | using ParentType = StaggeredGridVariablesView<ActualGridVariables>; | ||
145 | public: | ||
146 |
1/2✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
|
50 | using ParentType::ParentType; |
147 | |||
148 | //! initialize all variables (stationary case) | ||
149 | template<class SolVector> | ||
150 | void init(const SolVector& curSol) | ||
151 | { | ||
152 | this->curGridFaceVars().update(this->gridGeometry(), curSol); | ||
153 | this->prevGridFaceVars().update(this->gridGeometry(), curSol); | ||
154 | } | ||
155 | |||
156 | //! update the face variables | ||
157 | template<class SolVector> | ||
158 | void update(const SolVector& curSol) | ||
159 | { | ||
160 | ✗ | this->curGridFaceVars().update(this->gridGeometry(), curSol); | |
161 | } | ||
162 | |||
163 | //! resets state to the one before time integration | ||
164 | template<class SolVector> | ||
165 | ✗ | void resetTimeStep(const SolVector& sol) | |
166 | { | ||
167 | ✗ | this->curGridFaceVars() = this->prevGridFaceVars(); | |
168 | ✗ | } | |
169 | }; | ||
170 | |||
171 | |||
172 | |||
173 | /*! | ||
174 | * \ingroup StaggeredDiscretization | ||
175 | * \brief Class storing data associated to scvs and scvfs | ||
176 | * \tparam GG the type of the grid geometry | ||
177 | * \tparam GVV the type of the grid volume variables | ||
178 | * \tparam GFVC the type of the grid flux variables cache | ||
179 | * \tparam GFV the type of the grid face variables | ||
180 | */ | ||
181 | template<class GG, class GVV, class GFVC, class GFV> | ||
182 | class StaggeredGridVariables : public FVGridVariables<GG, GVV, GFVC> | ||
183 | { | ||
184 | using ParentType = FVGridVariables<GG, GVV, GFVC>; | ||
185 | using ThisType = StaggeredGridVariables<GG, GVV, GFVC, GFV>; | ||
186 | friend class StaggeredGridVariablesView<ThisType>; | ||
187 | |||
188 | static constexpr auto cellCenterIdx = GG::cellCenterIdx(); | ||
189 | static constexpr auto faceIdx = GG::faceIdx(); | ||
190 | |||
191 | public: | ||
192 | using CellCenterGridVariablesType = CellCenterGridVariablesView<ThisType>; | ||
193 | using FaceGridVariablesType = FaceGridVariablesView<ThisType>; | ||
194 | |||
195 | //! export the type of the grid volume variables | ||
196 | using GridVolumeVariables = GVV; | ||
197 | //! export the type of the grid flux variables cache | ||
198 | using GridFluxVariablesCache = GFVC; | ||
199 | //! export the type of the grid face variables | ||
200 | using GridFaceVariables = GFV; | ||
201 | //! export the type of the grid geometry | ||
202 | using GridGeometry = GG; | ||
203 | |||
204 | //! Constructor | ||
205 | template<class Problem> | ||
206 | 50 | StaggeredGridVariables(std::shared_ptr<Problem> problem, | |
207 | std::shared_ptr<GridGeometry> gridGeometry) | ||
208 | : ParentType(problem, gridGeometry) | ||
209 | 100 | , curGridFaceVariables_(*problem) | |
210 |
3/10✓ Branch 3 taken 50 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 50 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 50 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
300 | , prevGridFaceVariables_(*problem) |
211 | 50 | {} | |
212 | |||
213 | //! update all variables | ||
214 | template<class SolutionVector> | ||
215 | void update(const SolutionVector& curSol) | ||
216 | { | ||
217 | ParentType::update(curSol[cellCenterIdx]); | ||
218 | curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]); | ||
219 | } | ||
220 | |||
221 | //! initialize all variables (stationary case) | ||
222 | template<class SolutionVector> | ||
223 | 50 | void init(const SolutionVector& curSol) | |
224 | { | ||
225 | 100 | ParentType::init(curSol[cellCenterIdx]); | |
226 | 150 | curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]); | |
227 | 150 | prevGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]); | |
228 | 50 | } | |
229 | |||
230 | //! Sets the current state as the previous for next time step | ||
231 | //! this has to be called at the end of each time step | ||
232 | 1260 | void advanceTimeStep() | |
233 | { | ||
234 | 1260 | ParentType::advanceTimeStep(); | |
235 | 1260 | prevGridFaceVariables_ = curGridFaceVariables_; | |
236 | 1260 | } | |
237 | |||
238 | //! resets state to the one before time integration | ||
239 | template<class SolutionVector> | ||
240 | void resetTimeStep(const SolutionVector& solution) | ||
241 | { | ||
242 | ParentType::resetTimeStep(solution); | ||
243 | curGridFaceVariables_ = prevGridFaceVariables_; | ||
244 | } | ||
245 | |||
246 | //! return the current face variables | ||
247 | const GridFaceVariables& curGridFaceVars() const | ||
248 |
2/48✓ Branch 1 taken 143 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 49 not taken.
✗ Branch 50 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✗ Branch 64 not taken.
✗ Branch 65 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
|
469359 | { return curGridFaceVariables_; } |
249 | |||
250 | //! return the previous face variables | ||
251 | const GridFaceVariables& prevGridFaceVars() const | ||
252 | { return prevGridFaceVariables_; } | ||
253 | |||
254 | //! return the current face variables | ||
255 | GridFaceVariables& curGridFaceVars() | ||
256 | 50798752 | { return curGridFaceVariables_; } | |
257 | |||
258 | //! return the previous face variables | ||
259 | GridFaceVariables& prevGridFaceVars() | ||
260 | 2710888 | { return prevGridFaceVariables_; } | |
261 | |||
262 | //! Returns a pointer the cell center specific auxiliary class. Required for the multi-domain FVAssembler's ctor. | ||
263 | std::unique_ptr<CellCenterGridVariablesView<ThisType>> cellCenterGridVariablesPtr() | ||
264 | { | ||
265 |
1/2✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
|
50 | return std::make_unique<CellCenterGridVariablesView<ThisType>>(this); |
266 | } | ||
267 | |||
268 | //! Returns a pointer the face specific auxiliary class. Required for the multi-domain FVAssembler's ctor. | ||
269 | std::unique_ptr<FaceGridVariablesView<ThisType>> faceGridVariablesPtr() | ||
270 | { | ||
271 |
1/2✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
|
50 | return std::make_unique<FaceGridVariablesView<ThisType>>(this); |
272 | } | ||
273 | |||
274 | //! Return a copy of the cell center specific auxiliary class. | ||
275 | CellCenterGridVariablesView<ThisType> cellCenterGridVariables() const | ||
276 | { | ||
277 | return CellCenterGridVariablesView<ThisType>(this); | ||
278 | } | ||
279 | |||
280 | //! Return a copy of the face specific auxiliary class. | ||
281 | FaceGridVariablesView<ThisType> faceGridVariables() const | ||
282 | { | ||
283 | return FaceGridVariablesView<ThisType>(this); | ||
284 | } | ||
285 | |||
286 | |||
287 | private: | ||
288 | GridFaceVariables curGridFaceVariables_; | ||
289 | GridFaceVariables prevGridFaceVariables_; | ||
290 | }; | ||
291 | |||
292 | } // end namespace Dumux | ||
293 | |||
294 | #endif | ||
295 |