3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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_TPFA_SUBCONTROLVOLUMEFACE_HH
25#define DUMUX_DISCRETIZATION_CC_TPFA_SUBCONTROLVOLUMEFACE_HH
26
27#include <utility>
28#include <vector>
29
30#include <dune/common/reservedvector.hh>
31#include <dune/geometry/type.hh>
32#include <dune/geometry/multilineargeometry.hh>
33
37
38namespace Dumux {
39
46template<class GridView>
48{
49 using Grid = typename GridView::Grid;
50
51 static constexpr int dim = Grid::dimension;
52 static constexpr int dimWorld = Grid::dimensionworld;
53
54 using Scalar = typename Grid::ctype;
57 using GridIndexStorage = typename std::conditional_t< (dim<dimWorld),
58 std::vector<GridIndexType>,
59 Dune::ReservedVector<GridIndexType, 2> >;
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 = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
71 };
72 };
73
74 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
76 using GlobalPosition = typename CornerStorage::value_type;
78};
79
86template<class GV,
89: public SubControlVolumeFaceBase<CCTpfaSubControlVolumeFace<GV, T>, T>
90{
93 using GridIndexType = typename T::GridIndexType;
94 using Scalar = typename T::Scalar;
95 using CornerStorage = typename T::CornerStorage;
96 using GridIndexStorage = typename T::GridIndexStorage;
97 using Geometry = typename T::Geometry;
98 using BoundaryFlag = typename T::BoundaryFlag;
99
100public:
102 using GlobalPosition = typename T::GlobalPosition;
104 using Traits = T;
105
106 // the default constructor
108
118 template <class Intersection>
119 CCTpfaSubControlVolumeFace(const Intersection& is,
120 const typename Intersection::Geometry& isGeometry,
121 GridIndexType scvfIndex,
122 const GridIndexStorage& scvIndices,
123 bool isBoundary)
124 : ParentType()
125 , geomType_(isGeometry.type())
126 , area_(isGeometry.volume())
127 , center_(isGeometry.center())
128 , unitOuterNormal_(is.centerUnitOuterNormal())
129 , scvfIndex_(scvfIndex)
130 , scvIndices_(scvIndices)
131 , boundary_(isBoundary)
132 , boundaryFlag_{is}
133 {
134 corners_.resize(isGeometry.corners());
135 for (int i = 0; i < isGeometry.corners(); ++i)
136 corners_[i] = isGeometry.corner(i);
137 }
138
140 const GlobalPosition& center() const
141 {
142 return center_;
143 }
144
147 {
148 // Return center for now
149 return center_;
150 }
151
153 Scalar area() const
154 {
155 return area_;
156 }
157
159 bool boundary() const
160 {
161 return boundary_;
162 }
163
166 {
167 return unitOuterNormal_;
168 }
169
171 GridIndexType insideScvIdx() const
172 {
173 return scvIndices_[0];
174 }
175
177 // This results in undefined behaviour if boundary is true
178 GridIndexType outsideScvIdx(int i = 0) const
179 {
180 return scvIndices_[i+1];
181 }
182
184 std::size_t numOutsideScvs() const
185 {
186 return scvIndices_.size()-1;
187 }
188
190 GridIndexType index() const
191 {
192 return scvfIndex_;
193 }
194
196 const GlobalPosition& corner(int i) const
197 {
198 assert(i < corners_.size() && "provided index exceeds the number of corners");
199 return corners_[i];
200 }
201
203 Geometry geometry() const
204 {
205 return Geometry(geomType_, corners_);
206 }
207
210 {
211 return boundaryFlag_.get();
212 }
213
214private:
215 Dune::GeometryType geomType_;
216 CornerStorage corners_;
217 Scalar area_;
218 GlobalPosition center_;
219 GlobalPosition unitOuterNormal_;
220 GridIndexType scvfIndex_;
221 GridIndexStorage scvIndices_;
222 bool boundary_;
223 BoundaryFlag boundaryFlag_;
224};
225
226} // end namespace Dumux
227
228#endif
Defines the index types used for grid and local indices.
Boundary flag to store e.g. in sub control volume faces.
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 cell-centered finite volume ...
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:48
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:75
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:74
typename GridView::Grid Grid
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:49
static constexpr int dim
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:51
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:76
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:56
typename Grid::ctype Scalar
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:54
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:55
static constexpr int dimWorld
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:52
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 2 > > GridIndexStorage
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:59
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:64
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:69
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:70
The sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:90
bool boundary() const
returns bolean if the sub control volume face is on the boundary
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:159
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:102
const GlobalPosition & unitOuterNormal() const
The unit outer normal of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:165
GridIndexType outsideScvIdx(int i=0) const
index of the outside sub control volume for spatial param evaluation
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:178
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:209
const GlobalPosition & corner(int i) const
return the i-th corner of this sub control volume face
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:196
std::size_t numOutsideScvs() const
The number of outside scvs connection via this scv face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:184
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:140
GridIndexType insideScvIdx() const
index of the inside sub control volume for spatial param evaluation
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:171
T Traits
state the traits public and thus export all types
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:104
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:203
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:146
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:190
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:119
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/tpfa/subcontrolvolumeface.hh:153
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