version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
13#define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH
14
15#include <utility>
16#include <vector>
17#include <array>
18
19#include <dune/common/reservedvector.hh>
20#include <dune/common/fvector.hh>
21#include <dune/geometry/type.hh>
22#include <dune/geometry/multilineargeometry.hh>
23
26
27namespace Dumux {
28
35template<class GridView>
37{
38 using Grid = typename GridView::Grid;
39
40 static const int dim = Grid::dimension;
41 static const int dimWorld = Grid::dimensionworld;
42
43 using Scalar = typename Grid::ctype;
46 using OutsideGridIndexStorage = typename std::conditional_t< (dim<dimWorld),
47 std::vector<GridIndexType>,
48 Dune::ReservedVector<GridIndexType, 1> >;
49
50 // we use geometry traits that use static corner vectors to and a fixed geometry type
51 template <class ct>
52 struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
53 {
54 // we use static vectors to store the corners as we know
55 // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
56 template< int mydim, int cdim >
58 {
59 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
60 };
61
62 // we know all scvfs will have the same geometry type
63 template< int dim >
65 {
66 static const bool v = true;
67 static const unsigned int topologyId = Dune::GeometryTypes::cube(dim).id();
68 };
69 };
70
71 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
73 using GlobalPosition = typename CornerStorage::value_type;
75};
76
84template<class GV,
87{
88 using GridIndexType = typename T::GridIndexType;
89 using Scalar = typename T::Scalar;
90 using CornerStorage = typename T::CornerStorage;
91 using OutsideGridIndexStorage = typename T::OutsideGridIndexStorage;
92 using Geometry = typename T::Geometry;
93 using BoundaryFlag = typename T::BoundaryFlag;
94
95public:
96 // Information on the intersection from which this scvf was constructed
97 struct FacetInfo
98 {
99 GridIndexType elementIndex;
102 };
103
105 using GlobalPosition = typename T::GlobalPosition;
107 using Traits = T;
108
125 template<class MpfaHelper, class Intersection>
126 CCMpfaSubControlVolumeFace(const MpfaHelper& helper,
127 CornerStorage&& corners,
128 const Intersection& intersection,
130 GridIndexType vIdxGlobal,
131 unsigned int vIdxLocal,
132 GridIndexType scvfIndex,
133 GridIndexType insideScvIdx,
134 const OutsideGridIndexStorage& outsideScvIndices,
135 Scalar q,
136 bool boundary)
137 : boundary_(boundary)
138 , vertexIndex_(vIdxGlobal)
139 , scvfIndex_(scvfIndex)
140 , insideScvIdx_(insideScvIdx)
141 , outsideScvIndices_(outsideScvIndices)
142 , vIdxInElement_(vIdxLocal)
143 , corners_(std::move(corners))
144 , center_(0.0)
145 , unitOuterNormal_(intersection.centerUnitOuterNormal())
146 , boundaryFlag_{intersection}
147 , facetInfo_{std::move(facetInfo)}
148 {
149 // compute the center of the scvf
150 for (const auto& corner : corners_)
151 center_ += corner;
152 center_ /= corners_.size();
153
154 // use helper class to obtain area & integration point
155 ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
156 area_ = helper.computeScvfArea(corners_);
157 }
158
160 Scalar area() const
161 { return area_; }
162
164 bool boundary() const
165 { return boundary_; }
166
168 GridIndexType index() const
169 { return scvfIndex_; }
170
172 GridIndexType vertexIndex() const
173 { return vertexIndex_; }
174
176 unsigned int vertexIndexInElement() const
177 { return vIdxInElement_; }
178
180 GridIndexType insideScvIdx() const
181 { return insideScvIdx_; }
182
184 std::size_t numOutsideScvs() const
185 { return outsideScvIndices_.size(); }
186
188 // Results in undefined behaviour if i >= numOutsideScvs()
189 GridIndexType outsideScvIdx(int i = 0) const
190 { return outsideScvIndices_[i]; }
191
193 const OutsideGridIndexStorage& outsideScvIndices() const
194 { return outsideScvIndices_; }
195
197 [[deprecated("Will be removed after 3.8. Use fvGeometry.geometry(scvf).corners().")]]
198 std::size_t corners() const
199 { return corners_.size(); }
200
202 [[deprecated("Will be removed after 3.8. Use fvGeometry.vertexCorner(scvf)")]]
204 { return corners_.back(); }
205
207 [[deprecated("Will be removed after 3.8. Use fvGeometry.facetCorner(scvf)")]]
209 { return corners_[0]; }
210
212 const GlobalPosition& center() const
213 { return center_; }
214
217 { return ipGlobal_; }
218
221 { return unitOuterNormal_; }
222
225 { return boundaryFlag_.get(); }
226
228 const FacetInfo& facetInfo() const
229 { return facetInfo_; }
230
231private:
232 bool boundary_;
233 GridIndexType vertexIndex_;
234 GridIndexType scvfIndex_;
235 GridIndexType insideScvIdx_;
236 OutsideGridIndexStorage outsideScvIndices_;
237 unsigned int vIdxInElement_;
238
239 CornerStorage corners_;
240 GlobalPosition center_;
241 GlobalPosition ipGlobal_;
242 GlobalPosition unitOuterNormal_;
243 Scalar area_;
244 BoundaryFlag boundaryFlag_;
245 FacetInfo facetInfo_;
246};
247
248} // end namespace Dumux
249
250#endif
Boundary flag to store e.g. in sub control volume faces.
Boundary flag to store e.g. in sub control volume faces.
Definition: boundaryflag.hh:55
std::size_t value_type
Definition: boundaryflag.hh:39
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:87
std::size_t corners() const
Returns the number of corners.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:198
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:168
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:216
unsigned int vertexIndexInElement() const
Returns the element-local vertex index the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:176
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:160
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:105
GridIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:180
const GlobalPosition & vertexCorner() const
Returns the global position of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:203
CCMpfaSubControlVolumeFace(const MpfaHelper &helper, CornerStorage &&corners, const Intersection &intersection, FacetInfo facetInfo, GridIndexType vIdxGlobal, unsigned int vIdxLocal, GridIndexType scvfIndex, GridIndexType insideScvIdx, const OutsideGridIndexStorage &outsideScvIndices, Scalar q, bool boundary)
Constructor.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:126
const FacetInfo & facetInfo() const
Return information on the facet from which this scvf was constructed.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:228
const GlobalPosition & unitOuterNormal() const
returns the unit outer normal vector (assumes non-curved geometries)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:220
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:208
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:212
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:189
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:224
GridIndexType vertexIndex() const
Returns the index of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:172
const OutsideGridIndexStorage & outsideScvIndices() const
returns the outside scv indices (can be more than one index for dim < dimWorld)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:193
bool boundary() const
returns true if the sub control volume face is on the domain boundary
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:164
T Traits
state the traits public and thus export all types
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:107
std::size_t numOutsideScvs() const
The number of scvs on the outside of this scv face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:184
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:58
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:59
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:65
static const bool v
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:66
static const unsigned int topologyId
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:67
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:53
Default traits class to be used for the sub-control volume faces for the cell-centered finite volume ...
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:37
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:45
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:73
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:71
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:44
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:72
static const int dim
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:40
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 1 > > OutsideGridIndexStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:48
static const int dimWorld
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:41
typename Grid::ctype Scalar
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:43
typename GridView::Grid Grid
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:38
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:98
int facetCornerIndex
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:101
GridIndexType elementIndex
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:99
int facetIndex
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:100
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28