3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/cellcentered/mpfa/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_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
25#define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
26
27#include <vector>
28#include <array>
29
30#include <dune/common/reservedvector.hh>
31#include <dune/common/fvector.hh>
32#include <dune/geometry/type.hh>
33#include <dune/geometry/multilineargeometry.hh>
34
37
38namespace Dumux {
39
46template<class GridView>
48{
49 using Grid = typename GridView::Grid;
50
51 static const int dim = Grid::dimension;
52 static const int dimWorld = Grid::dimensionworld;
53
54 using Scalar = typename Grid::ctype;
57 using OutsideGridIndexStorage = typename std::conditional_t< (dim<dimWorld),
58 std::vector<GridIndexType>,
59 Dune::ReservedVector<GridIndexType, 1> >;
60
61 // we use geometry traits that use static corner vectors to and a fixed geometry type
62 template <class ct>
63 struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
64 {
65 // we use static vectors to store the corners as we know
66 // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
67 template< int mydim, int cdim >
69 {
70 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
71 };
72
73 // we know all scvfs will have the same geometry type
74 template< int dim >
76 {
77 static const bool v = true;
78 static const unsigned int topologyId = Dune::GeometryTypes::cube(dim).id();
79 };
80 };
81
82 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
84 using GlobalPosition = typename CornerStorage::value_type;
86};
87
95template<class GV,
98{
99 using GridIndexType = typename T::GridIndexType;
100 using Scalar = typename T::Scalar;
101 using CornerStorage = typename T::CornerStorage;
102 using OutsideGridIndexStorage = typename T::OutsideGridIndexStorage;
103 using Geometry = typename T::Geometry;
104 using BoundaryFlag = typename T::BoundaryFlag;
105
106public:
108 using GlobalPosition = typename T::GlobalPosition;
110 using Traits = T;
111
126 template<class MpfaHelper>
127 [[deprecated("Use constructor taking an intersection instead. Will be removed after release 3.5")]]
128 CCMpfaSubControlVolumeFace(const MpfaHelper& helper,
129 CornerStorage&& corners,
131 GridIndexType vIdxGlobal,
132 unsigned int vIdxLocal,
133 GridIndexType scvfIndex,
134 GridIndexType insideScvIdx,
135 const OutsideGridIndexStorage& outsideScvIndices,
136 Scalar q,
137 bool boundary)
138 : boundary_(boundary)
139 , vertexIndex_(vIdxGlobal)
140 , scvfIndex_(scvfIndex)
141 , insideScvIdx_(insideScvIdx)
142 , outsideScvIndices_(outsideScvIndices)
143 , vIdxInElement_(vIdxLocal)
144 , corners_(std::move(corners))
145 , center_(0.0)
146 , unitOuterNormal_(std::move(unitOuterNormal))
147 {
148 // compute the center of the scvf
149 for (const auto& corner : corners_)
150 center_ += corner;
151 center_ /= corners_.size();
152
153 // use helper class to obtain area & integration point
154 ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
155 area_ = helper.computeScvfArea(corners_);
156 }
157
159 template<class MpfaHelper, class Intersection>
160 CCMpfaSubControlVolumeFace(const MpfaHelper& helper,
161 CornerStorage&& corners,
162 const Intersection& intersection,
163 GridIndexType vIdxGlobal,
164 unsigned int vIdxLocal,
165 GridIndexType scvfIndex,
166 GridIndexType insideScvIdx,
167 const OutsideGridIndexStorage& outsideScvIndices,
168 Scalar q,
169 bool boundary)
170 : boundary_(boundary)
171 , vertexIndex_(vIdxGlobal)
172 , scvfIndex_(scvfIndex)
173 , insideScvIdx_(insideScvIdx)
174 , outsideScvIndices_(outsideScvIndices)
175 , vIdxInElement_(vIdxLocal)
176 , corners_(std::move(corners))
177 , center_(0.0)
178 , unitOuterNormal_(intersection.centerUnitOuterNormal())
179 , boundaryFlag_{intersection}
180 {
181 // compute the center of the scvf
182 for (const auto& corner : corners_)
183 center_ += corner;
184 center_ /= corners_.size();
185
186 // use helper class to obtain area & integration point
187 ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
188 area_ = helper.computeScvfArea(corners_);
189 }
190
192 Scalar area() const
193 { return area_; }
194
196 bool boundary() const
197 { return boundary_; }
198
200 GridIndexType index() const
201 { return scvfIndex_; }
202
204 GridIndexType vertexIndex() const
205 { return vertexIndex_; }
206
208 unsigned int vertexIndexInElement() const
209 { return vIdxInElement_; }
210
212 GridIndexType insideScvIdx() const
213 { return insideScvIdx_; }
214
216 std::size_t numOutsideScvs() const
217 { return outsideScvIndices_.size(); }
218
220 // Results in undefined behaviour if i >= numOutsideScvs()
221 GridIndexType outsideScvIdx(int i = 0) const
222 { return outsideScvIndices_[i]; }
223
225 const OutsideGridIndexStorage& outsideScvIndices() const
226 { return outsideScvIndices_; }
227
229 std::size_t corners() const
230 { return corners_.size(); }
231
233 const GlobalPosition& corner(unsigned int localIdx) const
234 {
235 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
236 return corners_[localIdx];
237 }
238
241 { return corners_.back(); }
242
245 { return corner(0); }
246
248 const GlobalPosition& center() const
249 { return center_; }
250
253 { return ipGlobal_; }
254
257 { return unitOuterNormal_; }
258
260 Geometry geometry() const
261 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
262
265 { return boundaryFlag_.get(); }
266
267private:
268 bool boundary_;
269 GridIndexType vertexIndex_;
270 GridIndexType scvfIndex_;
271 GridIndexType insideScvIdx_;
272 OutsideGridIndexStorage outsideScvIndices_;
273 unsigned int vIdxInElement_;
274
275 CornerStorage corners_;
276 GlobalPosition center_;
277 GlobalPosition ipGlobal_;
278 GlobalPosition unitOuterNormal_;
279 Scalar area_;
280 BoundaryFlag boundaryFlag_;
281};
282
283} // end namespace Dumux
284
285#endif
Boundary flag to store e.g. in sub control volume faces.
Defines the index types used for grid and local indices.
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 cell-centered finite volume ...
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:48
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:56
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:84
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:82
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:55
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:83
static const int dim
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:51
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 1 > > OutsideGridIndexStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:59
static const int dimWorld
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:52
typename Grid::ctype Scalar
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:54
typename GridView::Grid Grid
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:49
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:64
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:69
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:70
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:76
static const bool v
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:77
static const unsigned int topologyId
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:78
Class for a sub control volume face in mpfa methods, i.e a part of the boundary of a control volume w...
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:98
std::size_t corners() const
Returns the number of corners.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:229
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:200
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:252
unsigned int vertexIndexInElement() const
Returns the element-local vertex index the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:208
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:192
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:108
CCMpfaSubControlVolumeFace(const MpfaHelper &helper, CornerStorage &&corners, GlobalPosition &&unitOuterNormal, GridIndexType vIdxGlobal, unsigned int vIdxLocal, GridIndexType scvfIndex, GridIndexType insideScvIdx, const OutsideGridIndexStorage &outsideScvIndices, Scalar q, bool boundary)
Constructor.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:128
GridIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:212
const GlobalPosition & vertexCorner() const
Returns the global position of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:240
const GlobalPosition & unitOuterNormal() const
returns the unit outer normal vector (assumes non-curved geometries)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:256
const GlobalPosition & facetCorner() const
Returns the global position of the center of the element facet this scvf is embedded in.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:244
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:248
const GlobalPosition & corner(unsigned int localIdx) const
Returns the corner for a given local index.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:233
GridIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:221
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:264
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:260
GridIndexType vertexIndex() const
Returns the index of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:204
const OutsideGridIndexStorage & outsideScvIndices() const
returns the outside scv indices (can be more than one index for dim < dimWorld)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:225
CCMpfaSubControlVolumeFace(const MpfaHelper &helper, CornerStorage &&corners, const Intersection &intersection, GridIndexType vIdxGlobal, unsigned int vIdxLocal, GridIndexType scvfIndex, GridIndexType insideScvIdx, const OutsideGridIndexStorage &outsideScvIndices, Scalar q, bool boundary)
Construction with given intersection.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:160
bool boundary() const
returns true if the sub control volume face is on the domain boundary
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:196
T Traits
state the traits public and thus export all types
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:110
std::size_t numOutsideScvs() const
The number of scvs on the outside of this scv face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:216