version 3.7
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 <vector>
16#include <array>
17
18#include <dune/common/reservedvector.hh>
19#include <dune/common/fvector.hh>
20#include <dune/geometry/type.hh>
21#include <dune/geometry/multilineargeometry.hh>
22
25
26namespace Dumux {
27
34template<class GridView>
36{
37 using Grid = typename GridView::Grid;
38
39 static const int dim = Grid::dimension;
40 static const int dimWorld = Grid::dimensionworld;
41
42 using Scalar = typename Grid::ctype;
45 using OutsideGridIndexStorage = typename std::conditional_t< (dim<dimWorld),
46 std::vector<GridIndexType>,
47 Dune::ReservedVector<GridIndexType, 1> >;
48
49 // we use geometry traits that use static corner vectors to and a fixed geometry type
50 template <class ct>
51 struct ScvfMLGTraits : 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-1) corners (1<<(dim-1))
55 template< int mydim, int cdim >
57 {
58 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
59 };
60
61 // we know all scvfs will have the same geometry type
62 template< int dim >
64 {
65 static const bool v = true;
66 static const unsigned int topologyId = Dune::GeometryTypes::cube(dim).id();
67 };
68 };
69
70 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
72 using GlobalPosition = typename CornerStorage::value_type;
74};
75
83template<class GV,
86{
87 using GridIndexType = typename T::GridIndexType;
88 using Scalar = typename T::Scalar;
89 using CornerStorage = typename T::CornerStorage;
90 using OutsideGridIndexStorage = typename T::OutsideGridIndexStorage;
91 using Geometry = typename T::Geometry;
92 using BoundaryFlag = typename T::BoundaryFlag;
93
94public:
96 using GlobalPosition = typename T::GlobalPosition;
98 using Traits = T;
99
115 template<class MpfaHelper, class Intersection>
116 CCMpfaSubControlVolumeFace(const MpfaHelper& helper,
117 CornerStorage&& corners,
118 const Intersection& intersection,
119 GridIndexType vIdxGlobal,
120 unsigned int vIdxLocal,
121 GridIndexType scvfIndex,
122 GridIndexType insideScvIdx,
123 const OutsideGridIndexStorage& outsideScvIndices,
124 Scalar q,
125 bool boundary)
126 : boundary_(boundary)
127 , vertexIndex_(vIdxGlobal)
128 , scvfIndex_(scvfIndex)
129 , insideScvIdx_(insideScvIdx)
130 , outsideScvIndices_(outsideScvIndices)
131 , vIdxInElement_(vIdxLocal)
132 , corners_(std::move(corners))
133 , center_(0.0)
134 , unitOuterNormal_(intersection.centerUnitOuterNormal())
135 , boundaryFlag_{intersection}
136 {
137 // compute the center of the scvf
138 for (const auto& corner : corners_)
139 center_ += corner;
140 center_ /= corners_.size();
141
142 // use helper class to obtain area & integration point
143 ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
144 area_ = helper.computeScvfArea(corners_);
145 }
146
148 Scalar area() const
149 { return area_; }
150
152 bool boundary() const
153 { return boundary_; }
154
156 GridIndexType index() const
157 { return scvfIndex_; }
158
160 GridIndexType vertexIndex() const
161 { return vertexIndex_; }
162
164 unsigned int vertexIndexInElement() const
165 { return vIdxInElement_; }
166
168 GridIndexType insideScvIdx() const
169 { return insideScvIdx_; }
170
172 std::size_t numOutsideScvs() const
173 { return outsideScvIndices_.size(); }
174
176 // Results in undefined behaviour if i >= numOutsideScvs()
177 GridIndexType outsideScvIdx(int i = 0) const
178 { return outsideScvIndices_[i]; }
179
181 const OutsideGridIndexStorage& outsideScvIndices() const
182 { return outsideScvIndices_; }
183
185 std::size_t corners() const
186 { return corners_.size(); }
187
189 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).corner(i).")]]
190 const GlobalPosition& corner(unsigned int localIdx) const
191 {
192 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
193 return corners_[localIdx];
194 }
195
198 { return corners_.back(); }
199
202 { return corners_[0]; }
203
205 const GlobalPosition& center() const
206 { return center_; }
207
210 { return ipGlobal_; }
211
214 { return unitOuterNormal_; }
215
217 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
218 Geometry geometry() const
219 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
220
223 { return boundaryFlag_.get(); }
224
225private:
226 bool boundary_;
227 GridIndexType vertexIndex_;
228 GridIndexType scvfIndex_;
229 GridIndexType insideScvIdx_;
230 OutsideGridIndexStorage outsideScvIndices_;
231 unsigned int vIdxInElement_;
232
233 CornerStorage corners_;
234 GlobalPosition center_;
235 GlobalPosition ipGlobal_;
236 GlobalPosition unitOuterNormal_;
237 Scalar area_;
238 BoundaryFlag boundaryFlag_;
239};
240
241} // end namespace Dumux
242
243#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:86
std::size_t corners() const
Returns the number of corners.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:185
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:156
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:209
unsigned int vertexIndexInElement() const
Returns the element-local vertex index the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:164
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:148
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:96
GridIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:168
const GlobalPosition & vertexCorner() const
Returns the global position of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:197
const GlobalPosition & unitOuterNormal() const
returns the unit outer normal vector (assumes non-curved geometries)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:213
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:201
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:205
const GlobalPosition & corner(unsigned int localIdx) const
Returns the corner for a given local index.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:190
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:177
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:222
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:218
GridIndexType vertexIndex() const
Returns the index of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:160
const OutsideGridIndexStorage & outsideScvIndices() const
returns the outside scv indices (can be more than one index for dim < dimWorld)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:181
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)
Constructor.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:116
bool boundary() const
returns true if the sub control volume face is on the domain boundary
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:152
T Traits
state the traits public and thus export all types
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:98
std::size_t numOutsideScvs() const
The number of scvs on the outside of this scv face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:172
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:57
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:58
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:64
static const bool v
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:65
static const unsigned int topologyId
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:66
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:52
Default traits class to be used for the sub-control volume faces for the cell-centered finite volume ...
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:36
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:44
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:72
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:70
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:43
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:71
static const int dim
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:39
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 1 > > OutsideGridIndexStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:47
static const int dimWorld
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:40
typename Grid::ctype Scalar
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:42
typename GridView::Grid Grid
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:37
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28