3.3.0
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
51 explicit StaggeredGridVariablesView(ActualGridVariables* gridVariables)
53
56 { return gridVariables_->gridFluxVarsCache(); }
57
60 { return gridVariables_->gridFluxVarsCache(); }
61
64 { return gridVariables_->curGridVolVars(); }
65
68 { return gridVariables_->curGridVolVars(); }
69
72 { return gridVariables_->prevGridVolVars(); }
73
76 { return gridVariables_->prevGridVolVars(); }
77
80 { return gridVariables_->curGridFaceVars(); }
81
84 { return gridVariables_->prevGridFaceVars(); }
85
88 { return gridVariables_->curGridFaceVars(); }
89
92 { return gridVariables_->prevGridFaceVars(); }
93
96 { return (*gridVariables_->gridGeometry_); }
97
98 // return the actual grid variables
99 const ActualGridVariables& gridVariables() const
100 { return *gridVariables_; }
101
102 // return the actual grid variables
103 ActualGridVariables& gridVariables()
104 { return *gridVariables_; }
105
106protected:
107 ActualGridVariables* gridVariables_;
108};
109
115template<class ActualGridVariables>
117{
119public:
120 using ParentType::ParentType;
121
123 template<class SolVector>
124 void init(const SolVector& curSol)
125 {
126 this->curGridVolVars().update(this->gridGeometry(), curSol);
127 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol, true);
128 this->prevGridVolVars().update(this->gridGeometry(), curSol);
129 }
130
132 template<class SolVector>
133 void update(const SolVector& curSol)
134 {
135 this->curGridVolVars().update(this->gridGeometry(), curSol);
136 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), curSol);
137 }
138
140 template<class SolVector>
141 void resetTimeStep(const SolVector& sol)
142 {
143 this->curGridVolVars() = this->prevGridVolVars();
144 this->gridFluxVarsCache().update(this->gridGeometry(), this->curGridVolVars(), sol);
145 }
146};
147
153template<class ActualGridVariables>
154class FaceGridVariablesView : public StaggeredGridVariablesView<ActualGridVariables>
155{
157public:
158 using ParentType::ParentType;
159
161 template<class SolVector>
162 void init(const SolVector& curSol)
163 {
164 this->curGridFaceVars().update(this->gridGeometry(), curSol);
165 this->prevGridFaceVars().update(this->gridGeometry(), curSol);
166 }
167
169 template<class SolVector>
170 void update(const SolVector& curSol)
171 {
172 this->curGridFaceVars().update(this->gridGeometry(), curSol);
173 }
174
176 template<class SolVector>
177 void resetTimeStep(const SolVector& sol)
178 {
179 this->curGridFaceVars() = this->prevGridFaceVars();
180 }
181};
182
183
184
193template<class GG, class GVV, class GFVC, class GFV>
194class StaggeredGridVariables : public FVGridVariables<GG, GVV, GFVC>
195{
199
200 static constexpr auto cellCenterIdx = GG::cellCenterIdx();
201 static constexpr auto faceIdx = GG::faceIdx();
202
203public:
206
212 using GridFaceVariables = GFV;
214 using GridGeometry = GG;
215
217 template<class Problem>
218 StaggeredGridVariables(std::shared_ptr<Problem> problem,
219 std::shared_ptr<GridGeometry> gridGeometry)
220 : ParentType(problem, gridGeometry)
221 , curGridFaceVariables_(*problem)
222 , prevGridFaceVariables_(*problem)
223 {}
224
226 template<class SolutionVector>
227 void update(const SolutionVector& curSol)
228 {
229 ParentType::update(curSol[cellCenterIdx]);
230 curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
231 }
232
234 template<class SolutionVector>
235 void init(const SolutionVector& curSol)
236 {
237 ParentType::init(curSol[cellCenterIdx]);
238 curGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
239 prevGridFaceVariables_.update(*this->gridGeometry_, curSol[faceIdx]);
240 }
241
245 {
247 prevGridFaceVariables_ = curGridFaceVariables_;
248 }
249
251 template<class SolutionVector>
252 void resetTimeStep(const SolutionVector& solution)
253 {
255 curGridFaceVariables_ = prevGridFaceVariables_;
256 }
257
260 { return curGridFaceVariables_; }
261
264 { return prevGridFaceVariables_; }
265
268 { return curGridFaceVariables_; }
269
272 { return prevGridFaceVariables_; }
273
275 std::unique_ptr<CellCenterGridVariablesView<ThisType>> cellCenterGridVariablesPtr()
276 {
277 return std::make_unique<CellCenterGridVariablesView<ThisType>>(this);
278 }
279
281 std::unique_ptr<FaceGridVariablesView<ThisType>> faceGridVariablesPtr()
282 {
283 return std::make_unique<FaceGridVariablesView<ThisType>>(this);
284 }
285
288 {
290 }
291
294 {
296 }
297
298
299private:
300 GridFaceVariables curGridFaceVariables_;
301 GridFaceVariables prevGridFaceVariables_;
302};
303
304} // end namespace Dumux
305
306#endif
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:161
void advanceTimeStep()
Sets the current state as the previous for next time step.
Definition: discretization/fvgridvariables.hh:115
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:156
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:122
void update(const SolutionVector &curSol, bool forceFluxCacheUpdate=false)
update all variables
Definition: discretization/fvgridvariables.hh:90
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:87
typename ActualGridVariables::GridGeometry GridGeometry
Definition: discretization/staggered/gridvariables.hh:49
ActualGridVariables & gridVariables()
Definition: discretization/staggered/gridvariables.hh:103
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:83
const GridFluxVariablesCache & gridFluxVarsCache() const
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:55
GridFluxVariablesCache & gridFluxVarsCache()
return the flux variables cache
Definition: discretization/staggered/gridvariables.hh:59
GridVolumeVariables & curGridVolVars()
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:67
typename ActualGridVariables::GridFluxVariablesCache GridFluxVariablesCache
Definition: discretization/staggered/gridvariables.hh:42
const GridGeometry & gridGeometry() const
return the fv grid geometry
Definition: discretization/staggered/gridvariables.hh:95
const GridVolumeVariables & curGridVolVars() const
return the current volume variables
Definition: discretization/staggered/gridvariables.hh:63
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:91
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:79
const ActualGridVariables & gridVariables() const
Definition: discretization/staggered/gridvariables.hh:99
const GridVolumeVariables & prevGridVolVars() const
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:71
StaggeredGridVariablesView(ActualGridVariables *gridVariables)
Definition: discretization/staggered/gridvariables.hh:51
GridVolumeVariables & prevGridVolVars()
return the volume variables of the previous time step (for instationary problems)
Definition: discretization/staggered/gridvariables.hh:75
ActualGridVariables * gridVariables_
Definition: discretization/staggered/gridvariables.hh:107
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
Cell center specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:117
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:124
void update(const SolVector &curSol)
update the volume variables and the flux variables cache
Definition: discretization/staggered/gridvariables.hh:133
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:141
Face specific auxiliary GridVariables classes. Required for the Dumux multi-domain framework.
Definition: discretization/staggered/gridvariables.hh:155
void init(const SolVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:162
void update(const SolVector &curSol)
update the face variables
Definition: discretization/staggered/gridvariables.hh:170
void resetTimeStep(const SolVector &sol)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:177
Class storing data associated to scvs and scvfs.
Definition: discretization/staggered/gridvariables.hh:195
GFV GridFaceVariables
export the type of the grid face variables
Definition: discretization/staggered/gridvariables.hh:212
void update(const SolutionVector &curSol)
update all variables
Definition: discretization/staggered/gridvariables.hh:227
StaggeredGridVariables(std::shared_ptr< Problem > problem, std::shared_ptr< GridGeometry > gridGeometry)
Constructor.
Definition: discretization/staggered/gridvariables.hh:218
void init(const SolutionVector &curSol)
initialize all variables (stationary case)
Definition: discretization/staggered/gridvariables.hh:235
const GridFaceVariables & curGridFaceVars() const
return the current face variables
Definition: discretization/staggered/gridvariables.hh:259
FaceGridVariablesView< ThisType > faceGridVariables() const
Return a copy of the face specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:293
void resetTimeStep(const SolutionVector &solution)
resets state to the one before time integration
Definition: discretization/staggered/gridvariables.hh:252
void advanceTimeStep()
Definition: discretization/staggered/gridvariables.hh:244
CellCenterGridVariablesView< ThisType > cellCenterGridVariables() const
Return a copy of the cell center specific auxiliary class.
Definition: discretization/staggered/gridvariables.hh:287
GridFaceVariables & prevGridFaceVars()
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:271
GridFaceVariables & curGridFaceVars()
return the current face variables
Definition: discretization/staggered/gridvariables.hh:267
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:275
const GridFaceVariables & prevGridFaceVars() const
return the previous face variables
Definition: discretization/staggered/gridvariables.hh:263
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:281
The grid variable class for finite volume schemes storing variables on scv and scvf (volume and flux ...