version 3.7
discretization/cellcentered/tpfa/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_TPFA_SUBCONTROLVOLUMEFACE_HH
13#define DUMUX_DISCRETIZATION_CC_TPFA_SUBCONTROLVOLUMEFACE_HH
14
15#include <utility>
16#include <vector>
17
18#include <dune/common/reservedvector.hh>
19#include <dune/geometry/type.hh>
20#include <dune/geometry/multilineargeometry.hh>
21
25
26namespace Dumux {
27
34template<class GridView>
36{
37 using Grid = typename GridView::Grid;
38
39 static constexpr int dim = Grid::dimension;
40 static constexpr int dimWorld = Grid::dimensionworld;
41
42 using Scalar = typename Grid::ctype;
45 using GridIndexStorage = typename std::conditional_t< (dim<dimWorld),
46 std::vector<GridIndexType>,
47 Dune::ReservedVector<GridIndexType, 2> >;
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 = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
59 };
60 };
61
62 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
64 using GlobalPosition = typename CornerStorage::value_type;
66};
67
74template<class GV,
77: public SubControlVolumeFaceBase<CCTpfaSubControlVolumeFace<GV, T>, T>
78{
81 using GridIndexType = typename T::GridIndexType;
82 using Scalar = typename T::Scalar;
83 using CornerStorage = typename T::CornerStorage;
84 using GridIndexStorage = typename T::GridIndexStorage;
85 using Geometry = typename T::Geometry;
86 using BoundaryFlag = typename T::BoundaryFlag;
87
88public:
90 using GlobalPosition = typename T::GlobalPosition;
92 using Traits = T;
93
94 // the default constructor
96
106 template <class Intersection>
107 CCTpfaSubControlVolumeFace(const Intersection& is,
108 const typename Intersection::Geometry& isGeometry,
109 GridIndexType scvfIndex,
110 const GridIndexStorage& scvIndices,
111 bool isBoundary)
112 : ParentType()
113 , geomType_(isGeometry.type())
114 , area_(isGeometry.volume())
115 , center_(isGeometry.center())
116 , unitOuterNormal_(is.centerUnitOuterNormal())
117 , scvfIndex_(scvfIndex)
118 , scvIndices_(scvIndices)
119 , boundary_(isBoundary)
120 , boundaryFlag_{is}
121 {
122 corners_.resize(isGeometry.corners());
123 for (int i = 0; i < isGeometry.corners(); ++i)
124 corners_[i] = isGeometry.corner(i);
125 }
126
128 const GlobalPosition& center() const
129 {
130 return center_;
131 }
132
135 {
136 // Return center for now
137 return center_;
138 }
139
141 Scalar area() const
142 {
143 return area_;
144 }
145
147 bool boundary() const
148 {
149 return boundary_;
150 }
151
154 {
155 return unitOuterNormal_;
156 }
157
159 GridIndexType insideScvIdx() const
160 {
161 return scvIndices_[0];
162 }
163
165 // Results in undefined behaviour if i >= numOutsideScvs()
166 GridIndexType outsideScvIdx(int i = 0) const
167 {
168 return scvIndices_[i+1];
169 }
170
172 std::size_t numOutsideScvs() const
173 {
174 return scvIndices_.size()-1;
175 }
176
178 GridIndexType index() const
179 {
180 return scvfIndex_;
181 }
182
184 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).corner(i).")]]
185 const GlobalPosition& corner(int i) const
186 {
187 assert(i < corners_.size() && "provided index exceeds the number of corners");
188 return corners_[i];
189 }
190
192 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scvf).")]]
193 Geometry geometry() const
194 {
195 return Geometry(geomType_, corners_);
196 }
197
200 {
201 return boundaryFlag_.get();
202 }
203
204private:
205 Dune::GeometryType geomType_;
206 CornerStorage corners_;
207 Scalar area_;
208 GlobalPosition center_;
209 GlobalPosition unitOuterNormal_;
210 GridIndexType scvfIndex_;
211 GridIndexStorage scvIndices_;
212 bool boundary_;
213 BoundaryFlag boundaryFlag_;
214};
215
216} // end namespace Dumux
217
218#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
The sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:78
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:147
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:90
const GlobalPosition & unitOuterNormal() const
The unit outer normal of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:153
GridIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:166
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:199
const GlobalPosition & corner(int i) const
return the i-th corner of this sub control volume face
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:185
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:172
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:128
GridIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:159
T Traits
state the traits public and thus export all types
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:92
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:193
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:134
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:178
CCTpfaSubControlVolumeFace(const Intersection &is, const typename Intersection::Geometry &isGeometry, GridIndexType scvfIndex, const GridIndexStorage &scvIndices, bool isBoundary)
Constructor with intersection.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:107
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:141
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:29
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:159
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:57
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:58
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:52
Default traits class to be used for the sub-control volume faces for the cell-centered finite volume ...
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:36
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:63
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:62
typename GridView::Grid Grid
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:37
static constexpr int dim
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:39
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:64
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:44
typename Grid::ctype Scalar
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:42
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:43
static constexpr int dimWorld
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:40
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 2 > > GridIndexStorage
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:47
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Base class for a sub control volume face.