3.3.0
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
36
37namespace Dumux {
38
45template<class GridView>
47{
48 using Grid = typename GridView::Grid;
49
50 static const int dim = Grid::dimension;
51 static const int dimWorld = Grid::dimensionworld;
52
53 using Scalar = typename Grid::ctype;
56 using OutsideGridIndexStorage = typename std::conditional_t< (dim<dimWorld),
57 std::vector<GridIndexType>,
58 Dune::ReservedVector<GridIndexType, 1> >;
59
60 // we use geometry traits that use static corner vectors to and a fixed geometry type
61 template <class ct>
62 struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
63 {
64 // we use static vectors to store the corners as we know
65 // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
66 template< int mydim, int cdim >
68 {
69 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
70 };
71
72 // we know all scvfs will have the same geometry type
73 template< int dim >
75 {
76 static const bool v = true;
77 static const unsigned int topologyId = Dune::Impl::CubeTopology< dim >::type::id;
78 };
79 };
80
81 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar> >;
83 using GlobalPosition = typename CornerStorage::value_type;
84};
85
93template<class GV,
96{
97 using GridIndexType = typename T::GridIndexType;
98 using Scalar = typename T::Scalar;
99 using CornerStorage = typename T::CornerStorage;
100 using OutsideGridIndexStorage = typename T::OutsideGridIndexStorage;
101 using Geometry = typename T::Geometry;
102
103public:
105 using GlobalPosition = typename T::GlobalPosition;
107 using Traits = T;
108
123 template<class MpfaHelper>
124 CCMpfaSubControlVolumeFace(const MpfaHelper& helper,
125 CornerStorage&& corners,
127 GridIndexType vIdxGlobal,
128 unsigned int vIdxLocal,
129 GridIndexType scvfIndex,
130 GridIndexType insideScvIdx,
131 const OutsideGridIndexStorage& outsideScvIndices,
132 Scalar q,
133 bool boundary)
134 : boundary_(boundary)
135 , vertexIndex_(vIdxGlobal)
136 , scvfIndex_(scvfIndex)
137 , insideScvIdx_(insideScvIdx)
138 , outsideScvIndices_(outsideScvIndices)
139 , vIdxInElement_(vIdxLocal)
140 , corners_(std::move(corners))
141 , center_(0.0)
142 , unitOuterNormal_(std::move(unitOuterNormal))
143 {
144 // compute the center of the scvf
145 for (const auto& corner : corners_)
146 center_ += corner;
147 center_ /= corners_.size();
148
149 // use helper class to obtain area & integration point
150 ipGlobal_ = helper.getScvfIntegrationPoint(corners_, q);
151 area_ = helper.computeScvfArea(corners_);
152 }
153
155 Scalar area() const
156 { return area_; }
157
159 bool boundary() const
160 { return boundary_; }
161
163 GridIndexType index() const
164 { return scvfIndex_; }
165
167 GridIndexType vertexIndex() const
168 { return vertexIndex_; }
169
171 unsigned int vertexIndexInElement() const
172 { return vIdxInElement_; }
173
175 GridIndexType insideScvIdx() const
176 { return insideScvIdx_; }
177
179 std::size_t numOutsideScvs() const
180 { return outsideScvIndices_.size(); }
181
184 GridIndexType outsideScvIdx(int i = 0) const
185 { return outsideScvIndices_[i]; }
186
188 const OutsideGridIndexStorage& outsideScvIndices() const
189 { return outsideScvIndices_; }
190
192 std::size_t corners() const
193 { return corners_.size(); }
194
196 const GlobalPosition& corner(unsigned int localIdx) const
197 {
198 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
199 return corners_[localIdx];
200 }
201
204 { return corners_.back(); }
205
208 { return corner(0); }
209
211 const GlobalPosition& center() const
212 { return center_; }
213
216 { return ipGlobal_; }
217
220 { return unitOuterNormal_; }
221
223 Geometry geometry() const
224 { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); }
225
226private:
227 bool boundary_;
228 GridIndexType vertexIndex_;
229 GridIndexType scvfIndex_;
230 GridIndexType insideScvIdx_;
231 OutsideGridIndexStorage outsideScvIndices_;
232 unsigned int vIdxInElement_;
233
234 CornerStorage corners_;
235 GlobalPosition center_;
236 GlobalPosition ipGlobal_;
237 GlobalPosition unitOuterNormal_;
238 Scalar area_;
239};
240
241} // end namespace Dumux
242
243#endif
Defines the index types used for grid and local indices.
Definition: adapt.hh:29
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:47
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:55
typename CornerStorage::value_type GlobalPosition
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:83
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:81
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:54
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:82
static const int dim
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:50
typename std::conditional_t<(dim< dimWorld), std::vector< GridIndexType >, Dune::ReservedVector< GridIndexType, 1 > > OutsideGridIndexStorage
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:58
static const int dimWorld
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:51
typename Grid::ctype Scalar
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:53
typename GridView::Grid Grid
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:48
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:63
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:68
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:69
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:75
static const bool v
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:76
static const unsigned int topologyId
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:77
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:96
std::size_t corners() const
Returns the number of corners.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:192
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:163
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:215
unsigned int vertexIndexInElement() const
Returns the element-local vertex index the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:171
Scalar area() const
The area of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:155
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:105
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:124
GridIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:175
const GlobalPosition & vertexCorner() const
Returns the global position of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:203
const GlobalPosition & unitOuterNormal() const
returns the unit outer normal vector (assumes non-curved geometries)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:219
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:207
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:211
const GlobalPosition & corner(unsigned int localIdx) const
Returns the corner for a given local index.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:196
GridIndexType outsideScvIdx(int i=0) const
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:184
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:223
GridIndexType vertexIndex() const
Returns the index of the vertex the scvf is connected to.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:167
const OutsideGridIndexStorage & outsideScvIndices() const
returns the outside scv indices (can be more than one index for dim < dimWorld)
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:188
bool boundary() const
returns bolean if the sub control volume face is on the domain boundary
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:159
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 outside scvs connection via this scv face.
Definition: discretization/cellcentered/mpfa/subcontrolvolumeface.hh:179