3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/facecentered/staggered/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_FACECENTERED_STAGGERED_SUBCONTROLVOLUMEFACE_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUMEFACE_HH
26
27#include <array>
28#include <utility>
29
30#include <dune/common/fvector.hh>
31#include <dune/geometry/type.hh>
32#include <dune/geometry/axisalignedcubegeometry.hh>
33
37
38namespace Dumux {
39
46template<class GridView>
48{
51 using Scalar = typename GridView::ctype;
52 using Element = typename GridView::template Codim<0>::Entity;
53 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
54
55 static constexpr int dim = GridView::Grid::dimension;
56 static constexpr int dimWorld = GridView::Grid::dimensionworld;
57 using CornerStorage = std::array<GlobalPosition, (1<<(dim-1))>;
58 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim-1, dimWorld>;
59};
60
65template<class GridView, class T = FaceCenteredDefaultScvfGeometryTraits<GridView>>
67{
68 using Geometry = typename T::Geometry;
69 using GridIndexType = typename T::GridIndexType;
70 using Scalar = typename T::Scalar;
71 using Element = typename T::Element;
72 using CornerStorage = typename T::CornerStorage;
73
74 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
75
76 using ElementGeometry = typename Element::Geometry;
77 using IntersectionGeometry = typename GridView::Intersection::Geometry;
78
79public:
81 using Traits = T;
82
83 using GlobalPosition = typename T::GlobalPosition;
84 enum class FaceType : SmallLocalIndexType {frontal, lateral};
85 enum class BoundaryType : SmallLocalIndexType {interior, physicalBoundary, processorBoundary};
86
88
90 FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry& elementGeometry,
91 const IntersectionGeometry& intersectionGeometry,
92 const std::array<GridIndexType, 2> globalScvIndices,
93 const SmallLocalIndexType localScvfIdx,
94 const GridIndexType globalScvfIdx,
96 const FaceType faceType,
97 const BoundaryType boundaryType)
98 : globalScvIndices_(globalScvIndices)
99 , localScvfIdx_(localScvfIdx)
100 , globalScvfIdx_(globalScvfIdx)
101 , area_(intersectionGeometry.volume())
102 , normalAxis_(Dumux::normalAxis(unitOuterNormal))
103 , outerNormalSign_(sign(unitOuterNormal[normalAxis_]))
104 , faceType_(faceType)
105 , boundaryType_(boundaryType)
106 {
107 assert(faceType == FaceType::frontal);
108 center_ = boundary() ? intersectionGeometry.center() : elementGeometry.center();
109 ipGlobal_ = center_;
110
111 if (!boundary())
112 outerNormalSign_ *= -1.0;
113
114 // the corners (coincide with intersection corners for boundary scvfs)
115 const auto frontalOffSet = boundary() ? GlobalPosition(0.0)
116 : intersectionGeometry.center() - elementGeometry.center();
117
118 for (int i = 0; i < corners_.size(); ++i)
119 corners_[i] = intersectionGeometry.corner(i) + frontalOffSet;
120 }
121
123 template<class LateralFacetGeometry>
124 FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry& elementGeometry,
125 const IntersectionGeometry& intersectionGeometry,
126 const LateralFacetGeometry& lateralFacetGeometry,
127 const std::array<GridIndexType, 2> globalScvIndices,
128 const SmallLocalIndexType localScvfIdx,
129 const GridIndexType globalScvfIdx,
131 const FaceType faceType,
132 const BoundaryType boundaryType)
133 : globalScvIndices_(globalScvIndices)
134 , localScvfIdx_(localScvfIdx)
135 , globalScvfIdx_(globalScvfIdx)
136 , area_(0.5*lateralFacetGeometry.volume())
137 , normalAxis_(Dumux::normalAxis(unitOuterNormal))
138 , outerNormalSign_(sign(unitOuterNormal[normalAxis_]))
139 , faceType_(faceType)
140 , boundaryType_(boundaryType)
141 {
142 assert(faceType == FaceType::lateral);
143 const auto shift = intersectionGeometry.center() - elementGeometry.center();
144 ipGlobal_ = lateralFacetGeometry.center() + shift;
145 center_ = 0.5*(lateralFacetGeometry.center() + ipGlobal_);
146
147 const auto dofAxis = Dumux::normalAxis(shift);
148 const auto eps = shift.two_norm() * 1e-8;
149
150 for (int i = 0; i < corners_.size(); ++i)
151 {
152 // copy the corner of the corresponding lateral facet
153 auto& corner = corners_[i];
154 corner = lateralFacetGeometry.corner(i);
155
156 // shift the corner such that the scvf covers half of the lateral facet
157 // (keep the outer corner positions)
158 using std::abs;
159 if (abs(corner[dofAxis] - intersectionGeometry.center()[dofAxis]) > eps)
160 corner[dofAxis] = elementGeometry.center()[dofAxis];
161 }
162 }
163
165 const GlobalPosition& center() const
166 { return center_; }
167
170 { return ipGlobal_; }
171
174 {
175 GlobalPosition result(0.0);
176 result[normalAxis_] = 1.0 * directionSign();
177 return result;
178 }
179
181 GridIndexType insideScvIdx() const
182 { return globalScvIndices_[0]; }
183
185 GridIndexType outsideScvIdx() const
186 { return globalScvIndices_[1]; }
187
188 GridIndexType index() const
189 { return globalScvfIdx_; }
190
191 SmallLocalIndexType localIndex() const
192 { return localScvfIdx_; }
193
195 { return faceType_; }
196
197 bool boundary() const
198 { return boundaryType_ == BoundaryType::physicalBoundary; }
199
200 bool processorBoundary() const
201 { return boundaryType_ == BoundaryType::processorBoundary; }
202
203 bool isFrontal() const
204 { return faceType_ == FaceType::frontal; }
205
206 bool isLateral() const
207 { return faceType_ == FaceType::lateral; }
208
209 Scalar area() const
210 { return area_; }
211
212 SmallLocalIndexType normalAxis() const
213 { return normalAxis_; }
214
215 std::int_least8_t directionSign() const
216 { return outerNormalSign_; }
217
218 const GlobalPosition& corner(unsigned int localIdx) const
219 {
220 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
221 return corners_[localIdx];
222 }
223
225 Geometry geometry() const
226 {
227 auto inPlaneAxes = std::move(std::bitset<T::dimWorld>{}.set());
228 inPlaneAxes.set(normalAxis_, false);
229 return { corners_.front(), corners_.back(), inPlaneAxes };
230 }
231
232private:
233 GlobalPosition center_;
234 GlobalPosition ipGlobal_;
235 CornerStorage corners_;
236 std::array<GridIndexType, 2> globalScvIndices_;
237 SmallLocalIndexType localScvfIdx_;
238 GridIndexType globalScvfIdx_;
239 Scalar area_;
240 SmallLocalIndexType normalAxis_;
241 std::int_least8_t outerNormalSign_;
242 FaceType faceType_;
243 BoundaryType boundaryType_;
244};
245
246} // end namespace Dumux
247
248#endif
Defines the index types used for grid and local indices.
Base class for a sub control volume face.
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:171
static std::size_t normalAxis(const Vector &v)
Returns the normal axis index of a unit vector (0 = x, 1 = y, 2 = z)
Definition: normalaxis.hh:38
constexpr int sign(const ValueType &value) noexcept
Sign or signum function.
Definition: math.hh:641
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:41
unsigned int LocalIndex
Definition: indextraits.hh:40
Default traits class to be used for the sub-control volume face for the face-centered staggered finit...
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:48
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:49
std::array< GlobalPosition,(1<<(dim-1))> CornerStorage
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:57
static constexpr int dim
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:55
Dune::AxisAlignedCubeGeometry< Scalar, dim-1, dimWorld > Geometry
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:58
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:52
static constexpr int dimWorld
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:56
typename GridView::ctype Scalar
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:51
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:50
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:53
Face centered staggered sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:67
BoundaryType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:85
SmallLocalIndexType normalAxis() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:212
const GlobalPosition unitOuterNormal() const
The unit outer normal.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:173
FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry &elementGeometry, const IntersectionGeometry &intersectionGeometry, const LateralFacetGeometry &lateralFacetGeometry, const std::array< GridIndexType, 2 > globalScvIndices, const SmallLocalIndexType localScvfIdx, const GridIndexType globalScvfIdx, const GlobalPosition &unitOuterNormal, const FaceType faceType, const BoundaryType boundaryType)
The constructor for lateral faces.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:124
FaceType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:84
SmallLocalIndexType localIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:191
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:165
Scalar area() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:209
FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry &elementGeometry, const IntersectionGeometry &intersectionGeometry, const std::array< GridIndexType, 2 > globalScvIndices, const SmallLocalIndexType localScvfIdx, const GridIndexType globalScvfIdx, const GlobalPosition &unitOuterNormal, const FaceType faceType, const BoundaryType boundaryType)
The constructor for frontal faces.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:90
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:225
std::int_least8_t directionSign() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:215
GridIndexType outsideScvIdx() const
index of the outside sub control volume for spatial param evaluation
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:185
bool processorBoundary() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:200
const GlobalPosition & ipGlobal() const
The integration point of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:169
GridIndexType index() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:188
T Traits
state the traits public and thus export all types
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:81
const GlobalPosition & corner(unsigned int localIdx) const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:218
bool isFrontal() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:203
GridIndexType insideScvIdx() const
Index of the inside sub control volume for spatial param evaluation.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:181
typename T::GlobalPosition GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:83
bool isLateral() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:206
FaceType faceType() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:194
bool boundary() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:197