version 3.10-dev
discretization/staggered/gridvariables.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_STAGGERED_GRID_VARIABLES_HH
13#define DUMUX_STAGGERED_GRID_VARIABLES_HH
14
16
17namespace Dumux {
18
24template<class ActualGridVariables>
26{
27public:
28 using GridVolumeVariables = typename ActualGridVariables::GridVolumeVariables;
29 using GridFaceVariables = typename ActualGridVariables::GridFaceVariables;
30 using GridFluxVariablesCache = typename ActualGridVariables::GridFluxVariablesCache;
31
33 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
34
36 using PrimaryVariables = typename VolumeVariables::PrimaryVariables;
37 using GridGeometry = typename ActualGridVariables::GridGeometry;
38
39 explicit StaggeredGridVariablesView(ActualGridVariables* gridVariables)
41
44 { return gridVariables_->gridFluxVarsCache(); }
45
48 { return gridVariables_->gridFluxVarsCache(); }
49
52 { return gridVariables_->curGridVolVars(); }
53
56 { return gridVariables_->curGridVolVars(); }
57
60 { return gridVariables_->prevGridVolVars(); }
61
64 { return gridVariables_->prevGridVolVars(); }
65
68 { return gridVariables_->curGridFaceVars(); }
69
72 { return gridVariables_->prevGridFaceVars(); }
73
76 { return gridVariables_->curGridFaceVars(); }
77
80 { return gridVariables_->prevGridFaceVars(); }
81
84 { 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
94protected:
95 ActualGridVariables* gridVariables_;
96};
97
103template<class ActualGridVariables>
105{
107public:
108 using ParentType::ParentType;
109
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
120 template<class SolVector>
121 void update(const SolVector& curSol)
122 {
123 this->curGridVolVars().update(this->gridGeometry(), curSol);
124 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol);
125 }
126
128 template<class SolVector>
129 void resetTimeStep(const SolVector& sol)
130 {
131 this->curGridVolVars() = this->prevGridVolVars();
132 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), sol);
133 }
134};
135
141template<class ActualGridVariables>
142class FaceGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables>
143{
145public:
146 using ParentType::ParentType;
147
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
157 template<class SolVector>
158 void update(const SolVector& curSol)
159 {
160 this->curGridFaceVars().update(this->gridGeometry(), curSol);
161 }
162
164 template<class SolVector>
165 void resetTimeStep(const SolVector& sol)
166 {
167 this->curGridFaceVars() = this->prevGridFaceVars();
168 }
169};
170
171
172
181template<class GG, class GVV, class GFVC, class GFV>
182class StaggeredGridVariables : public FVGridVariables<GG, GVV, GFVC>
183{
187
188 static constexpr auto cellCenterIdx = GG::cellCenterIdx();
189 static constexpr auto faceIdx = GG::faceIdx();
190
191public:
194
200 using GridFaceVariables = GFV;
202 using GridGeometry = GG;
203
205 template<class Problem>
206 StaggeredGridVariables(std::shared_ptr<Problem> problem,
207 std::shared_ptr<GridGeometry> gridGeometry)
208 : ParentType(problem, gridGeometry)
209 , curGridFaceVariables_(*problem)
210 , prevGridFaceVariables_(*problem)
211 {}
212
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
222 template<class SolutionVector>
223 void init(const SolutionVector& curSol)
224 {
225 ParentType::init(curSol[cellCenterIdx]);
226 curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
227 prevGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
228 }
229
233 {
235 prevGridFaceVariables_ = curGridFaceVariables_;
236 }
237
239 template<class SolutionVector>
240 void resetTimeStep(const SolutionVector& solution)
241 {
243 curGridFaceVariables_ = prevGridFaceVariables_;
244 }
245
248 { return curGridFaceVariables_; }
249
252 { return prevGridFaceVariables_; }
253
256 { return curGridFaceVariables_; }
257
260 { return prevGridFaceVariables_; }
261
263 std::unique_ptr<CellCenterGridVariablesView<ThisType>> cellCenterGridVariablesPtr()
264 {
265 return std::make_unique<CellCenterGridVariablesView<ThisType>>(this);
266 }
267
269 std::unique_ptr<FaceGridVariablesView<ThisType>> faceGridVariablesPtr()
270 {
271 return std::make_unique<FaceGridVariablesView<ThisType>>(this);
272 }
273
276 {
278 }
279
282 {
284 }
285
286
287private:
288 GridFaceVariables curGridFaceVariables_;
289 GridFaceVariables prevGridFaceVariables_;
290};
291
292} // end namespace Dumux
293
294#endif
Cell center specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:105
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:112
void update(const SolVector &curSol)
update the volume variables and the flux variables cache
Definition: discretization/staggered/gridvariables.hh:121
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:129
The grid variable class for finite volume schemes storing variables on scv and scvf (volume and flux ...
Definition: discretization/fvgridvariables.hh:30
GG GridGeometry
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:33
std::shared_ptr< const GridGeometry > gridGeometry_
pointer to the constant grid geometry
Definition: discretization/fvgridvariables.hh:149
void advanceTimeStep()
Sets the current state as the previous for next time step.
Definition: discretization/fvgridvariables.hh:103
GVV GridVolumeVariables
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:36
void init(const SolutionVector &curSol)
initialize all variables (stationary case)
Definition: discretization/fvgridvariables.hh:61
const GridGeometry & gridGeometry() const
return the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:144
GFVC GridFluxVariablesCache
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:48
void resetTimeStep(const SolutionVector &solution)
resets state to the one before time integration
Definition: discretization/fvgridvariables.hh:110
void update(const SolutionVector &curSol, bool forceFluxCacheUpdate=false)
update all variables
Definition: discretization/fvgridvariables.hh:78
Face specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:143
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:150
void update(const SolVector &curSol)
update the face variables
Definition: discretization/staggered/gridvariables.hh:158
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:165
Class storing data associated to scvs and scvfs.
Definition: discretization/staggered/gridvariables.hh:183
GFV GridFaceVariables
export the type of the grid face variables
Definition: discretization/staggered/gridvariables.hh:200
void update(const SolutionVector &curSol)
update all variables
Definition: discretization/staggered/gridvariables.hh:215
StaggeredGridVariables(std::shared_ptr< Problem > problem, std::shared_ptr< GridGeometry > gridGeometry)
Constructor.
Definition: discretization/staggered/gridvariables.hh:206
void init(const SolutionVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:223
const GridFaceVariables & curGridFaceVars() const
return the current face variables
Definition: discretization/staggered/gridvariables.hh:247
FaceGridVariablesView< ThisType > faceGridVariables() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:281
void resetTimeStep(const SolutionVector &solution)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:240
void advanceTimeStep()
Definition: discretization/staggered/gridvariables.hh:232
CellCenterGridVariablesView< ThisType > cellCenterGridVariables() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:275
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:259
GridFaceVariables & curGridFaceVars()
return the current face variables
Definition: discretization/staggered/gridvariables.hh:255
std::unique_ptr< CellCenterGridVariablesView< ThisType > > cellCenterGridVariablesPtr()
Returns a pointer the cell center specific auxiliary class. Required for the multi-domain FVAssembler...
Definition: discretization/staggered/gridvariables.hh:263
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:251
std::unique_ptr< FaceGridVariablesView< ThisType > > faceGridVariablesPtr()
Returns a pointer the face specific auxiliary class. Required for the multi-domain FVAssembler's ctor...
Definition: discretization/staggered/gridvariables.hh:269
Base class for cell center of face specific auxiliary GridVariables classes. Provides a common interf...
Definition: discretization/staggered/gridvariables.hh:26
typename ActualGridVariables::GridFaceVariables GridFaceVariables
Definition: discretization/staggered/gridvariables.hh:29
GridFaceVariables & curGridFaceVars()
return the current face variables
Definition: discretization/staggered/gridvariables.hh:75
typename ActualGridVariables::GridGeometry GridGeometry
Definition: discretization/staggered/gridvariables.hh:37
ActualGridVariables & gridVariables()
Definition: discretization/staggered/gridvariables.hh:91
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:71
const GridFluxVariablesCache & gridFluxVarsCache() const
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:43
GridFluxVariablesCache & gridFluxVarsCache()
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:47
GridVolumeVariables & curGridVolVars()
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:55
typename ActualGridVariables::GridFluxVariablesCache GridFluxVariablesCache
Definition: discretization/staggered/gridvariables.hh:30
const GridGeometry & gridGeometry() const
return the fv grid geometry
Definition: discretization/staggered/gridvariables.hh:83
const GridVolumeVariables & curGridVolVars() const
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:51
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:79
typename VolumeVariables::PrimaryVariables PrimaryVariables
export primary variable type
Definition: discretization/staggered/gridvariables.hh:36
const GridFaceVariables & curGridFaceVars() const
return the current face variables
Definition: discretization/staggered/gridvariables.hh:67
const ActualGridVariables & gridVariables() const
Definition: discretization/staggered/gridvariables.hh:87
const GridVolumeVariables & prevGridVolVars() const
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:59
StaggeredGridVariablesView(ActualGridVariables *gridVariables)
Definition: discretization/staggered/gridvariables.hh:39
GridVolumeVariables & prevGridVolVars()
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:63
ActualGridVariables * gridVariables_
Definition: discretization/staggered/gridvariables.hh:95
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: discretization/staggered/gridvariables.hh:33
typename ActualGridVariables::GridVolumeVariables GridVolumeVariables
Definition: discretization/staggered/gridvariables.hh:28
The grid variable class for finite volume schemes, storing variables on scv and scvf (volume and flux...
Definition: adapt.hh:17