3.4
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
27// make the local view function available whenever we use this class
31
32namespace Dumux {
33
41template<class P, class FV>
43{
44 template<class GridFaceVariables, bool enableCache>
46
47 using FaceVariables = FV;
48 using Problem = P;
49};
50
55template<class Problem,
56 class FaceVariables,
57 bool cachingEnabled = false,
60
66template<class P, class FV, class Traits>
67class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>
68{
69 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>;
70 using Problem = typename Traits::Problem;
71
72public:
74 static constexpr bool cachingEnabled = true;
75
77 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
78
80 using FaceVariables = typename Traits::FaceVariables;
81
82 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
83
85 template<class GridGeometry, class SolutionVector>
86 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
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 const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry);
98 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
99 }
100 }
101 }
102
103 const FaceVariables& faceVars(const std::size_t facetIdx) const
104 { return faceVariables_[facetIdx]; }
105
106 FaceVariables& faceVars(const std::size_t facetIdx)
107 { return faceVariables_[facetIdx]; }
108
109 const Problem& problem() const
110 { return *problemPtr_; }
111
112private:
113 const Problem* problemPtr_;
114 std::vector<FaceVariables> faceVariables_;
115};
116
122template<class P, class FV, class Traits>
123class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>
124{
125 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>;
126 using Problem = typename Traits::Problem;
127
128public:
130 static constexpr bool cachingEnabled = false;
131
133 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
134
136 using FaceVariables = typename Traits::FaceVariables;
137
138 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
139
141 template<class GridGeometry, class SolutionVector>
142 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
143
144 const Problem& problem() const
145 { return *problemPtr_; }
146
147private:
148 const Problem* problemPtr_;
149};
150
151} // end namespace Dumux
152
153#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
Definition: adapt.hh:29
Base class for the face variables vector.
Definition: elementfacevariables.hh:39
The global face variables class for staggered models.
Definition: facesolution.hh:40
Traits class to be used for the StaggeredGridFaceVariables.
Definition: gridfacevariables.hh:43
P Problem
Definition: gridfacevariables.hh:48
FV FaceVariables
Definition: gridfacevariables.hh:47
Face variables cache class for staggered models.
Definition: gridfacevariables.hh:59
Face variables cache class for staggered models. Specialization in case of storing the face variables...
Definition: gridfacevariables.hh:68
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:77
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Update all face variables.
Definition: gridfacevariables.hh:86
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:80
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:82
const Problem & problem() const
Definition: gridfacevariables.hh:109
FaceVariables & faceVars(const std::size_t facetIdx)
Definition: gridfacevariables.hh:106
const FaceVariables & faceVars(const std::size_t facetIdx) const
Definition: gridfacevariables.hh:103
Face variables cache class for staggered models. Specialization in case of not storing the face varia...
Definition: gridfacevariables.hh:124
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:138
const Problem & problem() const
Definition: gridfacevariables.hh:144
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:136
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:133
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Do nothing here.
Definition: gridfacevariables.hh:142