3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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_STAGGERED_GRID_VARIABLES_HH
25#define DUMUX_STAGGERED_GRID_VARIABLES_HH
26
28
29namespace Dumux {
30
36template<class ActualGridVariables>
38{
39public:
40 using GridVolumeVariables = typename ActualGridVariables::GridVolumeVariables;
41 using GridFaceVariables = typename ActualGridVariables::GridFaceVariables;
42 using GridFluxVariablesCache = typename ActualGridVariables::GridFluxVariablesCache;
43
45 using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
46
48 using PrimaryVariables = typename VolumeVariables::PrimaryVariables;
49 using GridGeometry = typename ActualGridVariables::GridGeometry;
50 using FVGridGeometry [[deprecated ("Use GridGeometry instead. Will be removed after 3.1!")]]= GridGeometry;
51
52 explicit StaggeredGridVariablesView(ActualGridVariables* gridVariables)
54
57 { return gridVariables_->gridFluxVarsCache(); }
58
61 { return gridVariables_->gridFluxVarsCache(); }
62
65 { return gridVariables_->curGridVolVars(); }
66
69 { return gridVariables_->curGridVolVars(); }
70
73 { return gridVariables_->prevGridVolVars(); }
74
77 { return gridVariables_->prevGridVolVars(); }
78
81 { return gridVariables_->curGridFaceVars(); }
82
85 { return gridVariables_->prevGridFaceVars(); }
86
89 { return gridVariables_->curGridFaceVars(); }
90
93 { return gridVariables_->prevGridFaceVars(); }
94
96 [[deprecated("Use gridGeometry() instead. fvGridGeometry() will be removed after 3.1!")]]
98 { return (*gridVariables_->gridGeometry_); }
101 { return (*gridVariables_->gridGeometry_); }
102
103 // return the actual grid variables
104 const ActualGridVariables& gridVariables() const
105 { return *gridVariables_; }
106
107 // return the actual grid variables
108 ActualGridVariables& gridVariables()
109 { return *gridVariables_; }
110
111protected:
112 ActualGridVariables* gridVariables_;
113};
114
120template<class ActualGridVariables>
122{
124public:
125 using ParentType::ParentType;
126
128 template<class SolVector>
129 void init(const SolVector& curSol)
130 {
131 this->curGridVolVars().update(this->gridGeometry(), curSol);
132 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol, true);
133 this->prevGridVolVars().update(this->gridGeometry(), curSol);
134 }
135
137 template<class SolVector>
138 [[deprecated("Use init with one argument")]]
139 void init(const SolVector& curSol, const SolVector& initSol)
140 {
141 init(initSol);
142 }
143
145 template<class SolVector>
146 void update(const SolVector& curSol)
147 {
148 this->curGridVolVars().update(this->gridGeometry(), curSol);
149 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol);
150 }
151
153 template<class SolVector>
154 void resetTimeStep(const SolVector& sol)
155 {
156 this->curGridVolVars() = this->prevGridVolVars();
157 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), sol);
158 }
159};
160
166template<class ActualGridVariables>
167class FaceGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables>
168{
170public:
171 using ParentType::ParentType;
172
174 template<class SolVector>
175 void init(const SolVector& curSol)
176 {
177 this->curGridFaceVars().update(this->gridGeometry(), curSol);
178 this->prevGridFaceVars().update(this->gridGeometry(), curSol);
179 }
180
182 template<class SolVector>
183 [[deprecated("Use init with one argument")]]
184 void init(const SolVector& curSol, const SolVector& initSol)
185 {
186 init(initSol);
187 }
188
190 template<class SolVector>
191 void update(const SolVector& curSol)
192 {
193 this->curGridFaceVars().update(this->gridGeometry(), curSol);
194 }
195
197 template<class SolVector>
198 void resetTimeStep(const SolVector& sol)
199 {
200 this->curGridFaceVars() = this->prevGridFaceVars();
201 }
202};
203
204
205
214template<class GG, class GVV, class GFVC, class GFV>
215class StaggeredGridVariables : public FVGridVariables<GG, GVV, GFVC>
216{
220
221 static constexpr auto cellCenterIdx = GG::cellCenterIdx();
222 static constexpr auto faceIdx = GG::faceIdx();
223
224public:
227
233 using GridFaceVariables = GFV;
235 using GridGeometry = GG;
236
238 template<class Problem>
239 StaggeredGridVariables(std::shared_ptr<Problem> problem,
240 std::shared_ptr<GridGeometry> gridGeometry)
241 : ParentType(problem, gridGeometry)
242 , curGridFaceVariables_(*problem)
243 , prevGridFaceVariables_(*problem)
244 {}
245
247 template<class SolutionVector>
248 void update(const SolutionVector& curSol)
249 {
250 ParentType::update(curSol[cellCenterIdx]);
251 curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
252 }
253
255 template<class SolutionVector>
256 void init(const SolutionVector& curSol)
257 {
258 ParentType::init(curSol[cellCenterIdx]);
259 curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
260 prevGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
261 }
262
264 template<class SolutionVector>
265 [[deprecated("Use init with one argument")]]
266 void init(const SolutionVector& curSol, const SolutionVector& initSol)
267 {
268 init(initSol);
269 }
270
274 {
276 prevGridFaceVariables_ = curGridFaceVariables_;
277 }
278
280 template<class SolutionVector>
281 void resetTimeStep(const SolutionVector& solution)
282 {
284 curGridFaceVariables_ = prevGridFaceVariables_;
285 }
286
289 { return curGridFaceVariables_; }
290
293 { return prevGridFaceVariables_; }
294
297 { return curGridFaceVariables_; }
298
301 { return prevGridFaceVariables_; }
302
304 std::unique_ptr<CellCenterGridVariablesView<ThisType>> cellCenterGridVariablesPtr()
305 {
306 return std::make_unique<CellCenterGridVariablesView<ThisType>>(this);
307 }
308
310 std::unique_ptr<FaceGridVariablesView<ThisType>> faceGridVariablesPtr()
311 {
312 return std::make_unique<FaceGridVariablesView<ThisType>>(this);
313 }
314
317 {
319 }
320
323 {
325 }
326
327
328private:
329 GridFaceVariables curGridFaceVariables_;
330 GridFaceVariables prevGridFaceVariables_;
331};
332
333} // end namespace Dumux
334
335#endif
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
The grid variable class for finite volume schemes storing variables on scv and scvf (volume and flux ...
Definition: discretization/fvgridvariables.hh:42
GG GridGeometry
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:45
std::shared_ptr< const GridGeometry > gridGeometry_
pointer to the constant grid geometry
Definition: discretization/fvgridvariables.hh:175
void advanceTimeStep()
Sets the current state as the previous for next time step.
Definition: discretization/fvgridvariables.hh:124
GVV GridVolumeVariables
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:48
void init(const SolutionVector &curSol)
initialize all variables (stationary case)
Definition: discretization/fvgridvariables.hh:73
const GridGeometry & gridGeometry() const
return the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:170
GFVC GridFluxVariablesCache
export type of the finite volume grid geometry
Definition: discretization/fvgridvariables.hh:60
void resetTimeStep(const SolutionVector &solution)
resets state to the one before time integration
Definition: discretization/fvgridvariables.hh:131
void update(const SolutionVector &curSol, bool forceFluxCacheUpdate=false)
update all variables
Definition: discretization/fvgridvariables.hh:99
Base class for cell center of face specific auxiliary GridVariables classes. Provides a common interf...
Definition: discretization/staggered/gridvariables.hh:38
typename ActualGridVariables::GridFaceVariables GridFaceVariables
Definition: discretization/staggered/gridvariables.hh:41
GridFaceVariables & curGridFaceVars()
return the current face variables
Definition: discretization/staggered/gridvariables.hh:88
typename ActualGridVariables::GridGeometry GridGeometry
Definition: discretization/staggered/gridvariables.hh:49
ActualGridVariables & gridVariables()
Definition: discretization/staggered/gridvariables.hh:108
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:84
const GridFluxVariablesCache & gridFluxVarsCache() const
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:56
GridFluxVariablesCache & gridFluxVarsCache()
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:60
GridVolumeVariables & curGridVolVars()
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:68
typename ActualGridVariables::GridFluxVariablesCache GridFluxVariablesCache
Definition: discretization/staggered/gridvariables.hh:42
const GridGeometry & gridGeometry() const
return the fv grid geometry
Definition: discretization/staggered/gridvariables.hh:100
const GridVolumeVariables & curGridVolVars() const
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:64
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:92
typename VolumeVariables::PrimaryVariables PrimaryVariables
export primary variable type
Definition: discretization/staggered/gridvariables.hh:48
const GridFaceVariables & curGridFaceVars() const
return the current face variables
Definition: discretization/staggered/gridvariables.hh:80
const GridGeometry & fvGridGeometry() const
return the fv grid geometry
Definition: discretization/staggered/gridvariables.hh:97
const ActualGridVariables & gridVariables() const
Definition: discretization/staggered/gridvariables.hh:104
const GridVolumeVariables & prevGridVolVars() const
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:72
StaggeredGridVariablesView(ActualGridVariables *gridVariables)
Definition: discretization/staggered/gridvariables.hh:52
GridVolumeVariables & prevGridVolVars()
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:76
ActualGridVariables * gridVariables_
Definition: discretization/staggered/gridvariables.hh:112
typename GridVolumeVariables::VolumeVariables VolumeVariables
export type of the volume variables
Definition: discretization/staggered/gridvariables.hh:45
typename ActualGridVariables::GridVolumeVariables GridVolumeVariables
Definition: discretization/staggered/gridvariables.hh:40
GridGeometry FVGridGeometry
Definition: discretization/staggered/gridvariables.hh:50
Cell center specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:122
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:129
void init(const SolVector &curSol, const SolVector &initSol)
initialize all variables (instationary case)
Definition: discretization/staggered/gridvariables.hh:139
void update(const SolVector &curSol)
update the volume variables and the flux variables cache
Definition: discretization/staggered/gridvariables.hh:146
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:154
Face specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:168
void init(const SolVector &curSol, const SolVector &initSol)
initialize all variables (instationary case)
Definition: discretization/staggered/gridvariables.hh:184
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:175
void update(const SolVector &curSol)
update the face variables
Definition: discretization/staggered/gridvariables.hh:191
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:198
Class storing data associated to scvs and scvfs.
Definition: discretization/staggered/gridvariables.hh:216
void init(const SolutionVector &curSol, const SolutionVector &initSol)
initialize all variables (instationary case)
Definition: discretization/staggered/gridvariables.hh:266
GFV GridFaceVariables
export the type of the grid face variables
Definition: discretization/staggered/gridvariables.hh:233
void update(const SolutionVector &curSol)
update all variables
Definition: discretization/staggered/gridvariables.hh:248
StaggeredGridVariables(std::shared_ptr< Problem > problem, std::shared_ptr< GridGeometry > gridGeometry)
Constructor.
Definition: discretization/staggered/gridvariables.hh:239
void init(const SolutionVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:256
const GridFaceVariables & curGridFaceVars() const
return the current face variables
Definition: discretization/staggered/gridvariables.hh:288
FaceGridVariablesView< ThisType > faceGridVariables() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:322
void resetTimeStep(const SolutionVector &solution)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:281
void advanceTimeStep()
Definition: discretization/staggered/gridvariables.hh:273
CellCenterGridVariablesView< ThisType > cellCenterGridVariables() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:316
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:300
GridFaceVariables & curGridFaceVars()
return the current face variables
Definition: discretization/staggered/gridvariables.hh:296
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:304
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:292
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:310
The grid variable class for finite volume schemes storing variables on scv and scvf (volume and flux ...