3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/box/subcontrolvolume.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_BOX_SUBCONTROLVOLUME_HH
25#define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
26
27#include <dune/geometry/multilineargeometry.hh>
28
29#include <dumux/common/math.hh>
33
34namespace Dumux {
35
42template<class GridView>
44{
45 using Grid = typename GridView::Grid;
46
47 static const int dim = Grid::dimension;
48 static const int dimWorld = Grid::dimensionworld;
49
50 template <class ct>
51 struct ScvMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
52 {
53 // we use static vectors to store the corners as we know
54 // the number of corners in advance (2^(dim) corners (1<<(dim))
55 template< int mydim, int cdim >
57 {
58 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim)) >;
59 };
60
61 // we know all scvfs will have the same geometry type
62 template< int mydim >
64 {
65 static const bool v = true;
66 static const unsigned int topologyId = Dune::Impl::CubeTopology< mydim >::type::id;
67 };
68 };
69
72 using Scalar = typename Grid::ctype;
73 using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, ScvMLGTraits<Scalar>>;
75 using GlobalPosition = typename CornerStorage::value_type;
76};
77
84template<class GV,
87: public SubControlVolumeBase<BoxSubControlVolume<GV, T>, T>
88{
91 using Geometry = typename T::Geometry;
92 using GridIndexType = typename T::GridIndexType;
93 using LocalIndexType = typename T::LocalIndexType;
94 using Scalar = typename T::Scalar;
95 using CornerStorage = typename T::CornerStorage;
96 enum { dim = Geometry::mydimension };
97
98public:
100 using GlobalPosition = typename T::GlobalPosition;
102 using Traits = T;
103
106
107 // the contructor in the box case
108 template<class GeometryHelper>
109 BoxSubControlVolume(const GeometryHelper& geometryHelper,
110 LocalIndexType scvIdx,
111 GridIndexType elementIndex,
112 GridIndexType dofIndex)
113 : corners_(geometryHelper.getScvCorners(scvIdx)),
114 center_(0.0),
115 volume_(geometryHelper.scvVolume(corners_)),
116 elementIndex_(elementIndex),
117 localDofIdx_(scvIdx),
118 dofIndex_(dofIndex)
119 {
120 // compute center point
121 for (const auto& corner : corners_)
122 center_ += corner;
123 center_ /= corners_.size();
124 }
125
127 const GlobalPosition& center() const
128 {
129 return center_;
130 }
131
133 Scalar volume() const
134 {
135 return volume_;
136 }
137
139 // e.g. for integration
140 Geometry geometry() const
141 {
142 return Geometry(Dune::GeometryTypes::cube(dim), corners_);
143 }
144
146 LocalIndexType localDofIndex() const
147 {
148 return localDofIdx_;
149 }
150
153 LocalIndexType indexInElement() const
154 {
155 return localDofIdx_;
156 }
157
159 GridIndexType dofIndex() const
160 {
161 return dofIndex_;
162 }
163
164 // The position of the dof this scv is embedded in
166 {
167 // The corner list is defined such that the first entry is the vertex itself
168 return corners_[0];
169 }
170
172 GridIndexType elementIndex() const
173 {
174 return elementIndex_;
175 }
176
178 const GlobalPosition& corner(LocalIndexType localIdx) const
179 {
180 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
181 return corners_[localIdx];
182 }
183
184private:
185 CornerStorage corners_;
186 GlobalPosition center_;
187 Scalar volume_;
188 GridIndexType elementIndex_;
189 LocalIndexType localDofIdx_;
190 GridIndexType dofIndex_;
191};
192
193} // end namespace Dumux
194
195#endif
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Base class for a sub control volume.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Default traits class to be used for the sub-control volumes for the box scheme.
Definition: discretization/box/subcontrolvolume.hh:44
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolume.hh:45
Dune::MultiLinearGeometry< Scalar, dim, dimWorld, ScvMLGTraits< Scalar > > Geometry
Definition: discretization/box/subcontrolvolume.hh:73
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolume.hh:70
typename ScvMLGTraits< Scalar >::template CornerStorage< dim, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolume.hh:74
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolume.hh:71
static const int dim
Definition: discretization/box/subcontrolvolume.hh:47
static const int dimWorld
Definition: discretization/box/subcontrolvolume.hh:48
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolume.hh:72
typename CornerStorage::value_type GlobalPosition
Definition: discretization/box/subcontrolvolume.hh:75
Definition: discretization/box/subcontrolvolume.hh:52
Definition: discretization/box/subcontrolvolume.hh:57
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim)) > Type
Definition: discretization/box/subcontrolvolume.hh:58
Definition: discretization/box/subcontrolvolume.hh:64
static const bool v
Definition: discretization/box/subcontrolvolume.hh:65
static const unsigned int topologyId
Definition: discretization/box/subcontrolvolume.hh:66
the sub control volume for the box scheme
Definition: discretization/box/subcontrolvolume.hh:88
Geometry geometry() const
The geometry of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:140
const GlobalPosition & corner(LocalIndexType localIdx) const
Return the corner for the given local index.
Definition: discretization/box/subcontrolvolume.hh:178
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolume.hh:102
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:146
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:127
BoxSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolume.hh:100
LocalIndexType indexInElement() const
Definition: discretization/box/subcontrolvolume.hh:153
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:172
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:159
Scalar volume() const
The volume of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:133
const GlobalPosition & dofPosition() const
Definition: discretization/box/subcontrolvolume.hh:165
BoxSubControlVolume(const GeometryHelper &geometryHelper, LocalIndexType scvIdx, GridIndexType elementIndex, GridIndexType dofIndex)
Definition: discretization/box/subcontrolvolume.hh:109
Base class for a sub control volume, i.e a part of the control volume we are making the balance for....
Definition: subcontrolvolumebase.hh:38