3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/box/subcontrolvolumeface.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_SUBCONTROLVOLUMEFACE_HH
25#define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH
26
27#include <utility>
28
29#include <dune/geometry/type.hh>
30#include <dune/geometry/multilineargeometry.hh>
31
36
37namespace Dumux {
38
45template<class GridView>
47{
48 using Grid = typename GridView::Grid;
49 static constexpr int dim = Grid::dimension;
50 static constexpr int dimWorld = Grid::dimensionworld;
51
52 // we use geometry traits that use static corner vectors to and a fixed geometry type
53 template <class ct>
54 struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
55 {
56 // we use static vectors to store the corners as we know
57 // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
58 template< int mydim, int cdim >
60 {
61 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
62 };
63
64 // we know all scvfs will have the same geometry type
65 template< int mydim >
67 {
68 static const bool v = true;
69 static const unsigned int topologyId = Dune::Impl::CubeTopology< mydim >::type::id;
70 };
71 };
72
75 using Scalar = typename Grid::ctype;
76 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar>>;
78 using GlobalPosition = typename CornerStorage::value_type;
80};
81
89template<class GV,
92: public SubControlVolumeFaceBase<BoxSubControlVolumeFace<GV, T>, T>
93{
96 using GridIndexType = typename T::GridIndexType;
97 using LocalIndexType = typename T::LocalIndexType;
98 using Scalar = typename T::Scalar;
99 using CornerStorage = typename T::CornerStorage;
100 using Geometry = typename T::Geometry;
101 using BoundaryFlag = typename T::BoundaryFlag;
102
103public:
105 using GlobalPosition = typename T::GlobalPosition;
107 using Traits = T;
108
111
113 template<class GeometryHelper, class Element>
114 BoxSubControlVolumeFace(const GeometryHelper& geometryHelper,
115 const Element& element,
116 const typename Element::Geometry& elemGeometry,
117 GridIndexType scvfIndex,
118 std::vector<LocalIndexType>&& scvIndices,
119 bool boundary = false)
120 : corners_(geometryHelper.getScvfCorners(scvfIndex)),
121 center_(0.0),
122 unitOuterNormal_(geometryHelper.normal(corners_, scvIndices)),
123 area_(geometryHelper.scvfArea(corners_)),
124 scvfIndex_(scvfIndex),
125 scvIndices_(std::move(scvIndices)),
126 boundary_(boundary)
127 , boundaryFlag_{}
128 {
129 for (const auto& corner : corners_)
130 center_ += corner;
131 center_ /= corners_.size();
132 }
133
135 template<class GeometryHelper, class Intersection>
136 BoxSubControlVolumeFace(const GeometryHelper& geometryHelper,
137 const Intersection& intersection,
138 const typename Intersection::Geometry& isGeometry,
139 LocalIndexType indexInIntersection,
140 GridIndexType scvfIndex,
141 std::vector<LocalIndexType>&& scvIndices,
142 bool boundary = false)
143 : corners_(geometryHelper.getBoundaryScvfCorners(intersection, isGeometry, indexInIntersection)),
144 center_(0.0),
145 unitOuterNormal_(intersection.centerUnitOuterNormal()),
146 area_(geometryHelper.scvfArea(corners_)),
147 scvfIndex_(scvfIndex),
148 scvIndices_(std:: move(scvIndices)),
149 boundary_(boundary)
150 , boundaryFlag_{intersection}
151 {
152 for (const auto& corner : corners_)
153 center_ += corner;
154 center_ /= corners_.size();
155 }
156
158 const GlobalPosition& center() const
159 {
160 return center_;
161 }
162
165 {
166 return center_;
167 }
168
170 Scalar area() const
171 {
172 return area_;
173 }
174
176 bool boundary() const
177 {
178 return boundary_;
179 }
180
182 {
183 return unitOuterNormal_;
184 }
185
187 LocalIndexType insideScvIdx() const
188 {
189 return scvIndices_[0];
190 }
191
193 // This results in undefined behaviour if boundary is true
194 LocalIndexType outsideScvIdx() const
195 {
196 assert(!boundary());
197 return scvIndices_[1];
198 }
199
201 GridIndexType index() const
202 {
203 return scvfIndex_;
204 }
205
206 const GlobalPosition& corner(unsigned int localIdx) const
207 {
208 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
209 return corners_[localIdx];
210 }
211
213 Geometry geometry() const
214 {
215 return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_);
216 }
217
220 {
221 return boundaryFlag_.get();
222 }
223
224private:
225 CornerStorage corners_;
226 GlobalPosition center_;
227 GlobalPosition unitOuterNormal_;
228 Scalar area_;
229 GridIndexType scvfIndex_;
230 std::vector<LocalIndexType> scvIndices_;
231 bool boundary_;
232 BoundaryFlag boundaryFlag_;
233};
234
235} // end namespace Dumux
236
237#endif
Defines the index types used for grid and local indices.
Boundary flag to store e.g. in sub control volume faces.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Base class for a sub control volume face.
Definition: adapt.hh:29
std::size_t value_type
Definition: boundaryflag.hh:51
Definition: boundaryflag.hh:68
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 volume faces for the box scheme.
Definition: discretization/box/subcontrolvolumeface.hh:47
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/box/subcontrolvolumeface.hh:76
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolumeface.hh:75
typename CornerStorage::value_type GlobalPosition
Definition: discretization/box/subcontrolvolumeface.hh:78
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolumeface.hh:48
static constexpr int dimWorld
Definition: discretization/box/subcontrolvolumeface.hh:50
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolumeface.hh:74
static constexpr int dim
Definition: discretization/box/subcontrolvolumeface.hh:49
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolumeface.hh:73
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolumeface.hh:77
Definition: discretization/box/subcontrolvolumeface.hh:55
Definition: discretization/box/subcontrolvolumeface.hh:60
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/box/subcontrolvolumeface.hh:61
Definition: discretization/box/subcontrolvolumeface.hh:67
static const bool v
Definition: discretization/box/subcontrolvolumeface.hh:68
static const unsigned int topologyId
Definition: discretization/box/subcontrolvolumeface.hh:69
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition: discretization/box/subcontrolvolumeface.hh:93
const GlobalPosition & unitOuterNormal() const
Definition: discretization/box/subcontrolvolumeface.hh:181
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolumeface.hh:107
GridIndexType index() const
The local index of this sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:201
BoxSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary=false)
Constructor for boundary scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:136
BoxSubControlVolumeFace()=default
The default constructor.
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:158
bool boundary() const
returns bolean if the sub control volume face is on the boundary
Definition: discretization/box/subcontrolvolumeface.hh:176
LocalIndexType insideScvIdx() const
index of the inside sub control volume for spatial param evaluation
Definition: discretization/box/subcontrolvolumeface.hh:187
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/box/subcontrolvolumeface.hh:219
const GlobalPosition & corner(unsigned int localIdx) const
Definition: discretization/box/subcontrolvolumeface.hh:206
LocalIndexType outsideScvIdx() const
index of the outside sub control volume for spatial param evaluation
Definition: discretization/box/subcontrolvolumeface.hh:194
BoxSubControlVolumeFace(const GeometryHelper &geometryHelper, const Element &element, const typename Element::Geometry &elemGeometry, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary=false)
Constructor for inner scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:114
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/box/subcontrolvolumeface.hh:164
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolumeface.hh:105
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:213
Scalar area() const
The area of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:170
Base class for a sub control volume face, i.e a part of the boundary of a sub control volume we compu...
Definition: subcontrolvolumefacebase.hh:41