3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
gridfacevariables.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_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH
25#define DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH
26
30
31namespace Dumux {
32
40template<class P, class FV>
42{
43 template<class GridFaceVariables, bool enableCache>
45
46 using FaceVariables = FV;
47 using Problem = P;
48};
49
54template<class Problem,
55 class FaceVariables,
56 bool cachingEnabled = false,
59
65template<class P, class FV, class Traits>
66class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>
67{
68 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>;
69 using Problem = typename Traits::Problem;
70
71public:
73 static constexpr bool cachingEnabled = true;
74
76 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
77
79 using FaceVariables = typename Traits::FaceVariables;
80
81 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
82
84 template<class GridGeometry, class SolutionVector>
85 void update(const GridGeometry& gridGeometry, const SolutionVector& faceSol)
86 {
87
88 faceVariables_.resize(gridGeometry.numScvf());
89
90 for(auto&& element : elements(gridGeometry.gridView()))
91 {
92 auto fvGeometry = localView(gridGeometry);
93 fvGeometry.bindElement(element);
94
95 for(auto&& scvf : scvfs(fvGeometry))
96 {
97 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
98 }
99 }
100 }
101
102 const FaceVariables& faceVars(const std::size_t facetIdx) const
103 { return faceVariables_[facetIdx]; }
104
105 FaceVariables& faceVars(const std::size_t facetIdx)
106 { return faceVariables_[facetIdx]; }
107
108 const Problem& problem() const
109 { return *problemPtr_; }
110
111private:
112 const Problem* problemPtr_;
113 std::vector<FaceVariables> faceVariables_;
114};
115
121template<class P, class FV, class Traits>
122class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>
123{
124 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>;
125 using Problem = typename Traits::Problem;
126
127public:
129 static constexpr bool cachingEnabled = false;
130
132 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
133
135 using FaceVariables = typename Traits::FaceVariables;
136
137 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
138
140 template<class GridGeometry, class SolutionVector>
141 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
142
143 const Problem& problem() const
144 { return *problemPtr_; }
145
146private:
147 const Problem* problemPtr_;
148};
149
150} // end namespace Dumux
151
152#endif
Free function to get the local view of a grid cache object.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Base class for the face variables vector.
Definition: elementfacevariables.hh:39
Traits class to be used for the StaggeredGridFaceVariables.
Definition: gridfacevariables.hh:42
P Problem
Definition: gridfacevariables.hh:47
FV FaceVariables
Definition: gridfacevariables.hh:46
Face variables cache class for staggered models.
Definition: gridfacevariables.hh:58
Face variables cache class for staggered models. Specialization in case of storing the face variables...
Definition: gridfacevariables.hh:67
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:76
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:79
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:81
const Problem & problem() const
Definition: gridfacevariables.hh:108
FaceVariables & faceVars(const std::size_t facetIdx)
Definition: gridfacevariables.hh:105
const FaceVariables & faceVars(const std::size_t facetIdx) const
Definition: gridfacevariables.hh:102
void update(const GridGeometry &gridGeometry, const SolutionVector &faceSol)
Update all face variables.
Definition: gridfacevariables.hh:85
Face variables cache class for staggered models. Specialization in case of not storing the face varia...
Definition: gridfacevariables.hh:123
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:137
const Problem & problem() const
Definition: gridfacevariables.hh:143
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:135
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:132
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Do nothing here.
Definition: gridfacevariables.hh:141