version 3.8
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// 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_FACECENTERED_STAGGERED_SUBCONTROLVOLUMEFACE_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUMEFACE_HH
14
15#include <array>
16
17#include <dune/common/fvector.hh>
18#include <dune/geometry/type.hh>
19#include <dune/geometry/axisalignedcubegeometry.hh>
20
24
25namespace Dumux {
26
33template<class GridView>
35{
38 using Scalar = typename GridView::ctype;
39 using Element = typename GridView::template Codim<0>::Entity;
40 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
41
42 static constexpr int dim = GridView::Grid::dimension;
43 static constexpr int dimWorld = GridView::Grid::dimensionworld;
44 using CornerStorage = std::array<GlobalPosition, (1<<(dim-1))>;
45 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim-1, dimWorld>;
46};
47
52template<class GridView, class T = FaceCenteredDefaultScvfGeometryTraits<GridView>>
54{
55 using Geometry = typename T::Geometry;
56 using GridIndexType = typename T::GridIndexType;
57 using Scalar = typename T::Scalar;
58 using Element = typename T::Element;
59 using CornerStorage = typename T::CornerStorage;
60
61 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
62
63 using ElementGeometry = typename Element::Geometry;
64 using IntersectionGeometry = typename GridView::Intersection::Geometry;
65
66public:
68 using Traits = T;
69
70 using GlobalPosition = typename T::GlobalPosition;
71 enum class FaceType : SmallLocalIndexType {frontal, lateral};
72 enum class BoundaryType : SmallLocalIndexType {interior, physicalBoundary, processorBoundary};
73
75
77 FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry& elementGeometry,
78 const IntersectionGeometry& intersectionGeometry,
79 const std::array<GridIndexType, 2> globalScvIndices,
80 const SmallLocalIndexType localScvfIdx,
81 const GridIndexType globalScvfIdx,
83 const FaceType faceType,
84 const BoundaryType boundaryType)
85 : globalScvIndices_(globalScvIndices)
86 , localScvfIdx_(localScvfIdx)
87 , globalScvfIdx_(globalScvfIdx)
88 , area_(intersectionGeometry.volume())
89 , normalAxis_(Dumux::normalAxis(unitOuterNormal))
90 , outerNormalSign_(sign(unitOuterNormal[normalAxis_]))
91 , faceType_(faceType)
92 , boundaryType_(boundaryType)
93 {
94 assert(faceType == FaceType::frontal);
95 center_ = boundary() ? intersectionGeometry.center() : elementGeometry.center();
96 ipGlobal_ = center_;
97
98 if (!boundary())
99 outerNormalSign_ *= -1.0;
100 }
101
103 template<class LateralFacetGeometry>
104 FaceCenteredStaggeredSubControlVolumeFace(const ElementGeometry& elementGeometry,
105 const IntersectionGeometry& intersectionGeometry,
106 const LateralFacetGeometry& lateralFacetGeometry,
107 const std::array<GridIndexType, 2> globalScvIndices,
108 const SmallLocalIndexType localScvfIdx,
109 const GridIndexType globalScvfIdx,
111 const FaceType faceType,
112 const BoundaryType boundaryType)
113 : globalScvIndices_(globalScvIndices)
114 , localScvfIdx_(localScvfIdx)
115 , globalScvfIdx_(globalScvfIdx)
116 , area_(0.5*lateralFacetGeometry.volume())
117 , normalAxis_(Dumux::normalAxis(unitOuterNormal))
118 , outerNormalSign_(sign(unitOuterNormal[normalAxis_]))
119 , faceType_(faceType)
120 , boundaryType_(boundaryType)
121 {
122 assert(faceType == FaceType::lateral);
123 const auto shift = intersectionGeometry.center() - elementGeometry.center();
124 ipGlobal_ = lateralFacetGeometry.center() + shift;
125 center_ = 0.5*(lateralFacetGeometry.center() + ipGlobal_);
126 }
127
129 const GlobalPosition& center() const
130 { return center_; }
131
134 { return ipGlobal_; }
135
138 {
139 GlobalPosition result(0.0);
140 result[normalAxis_] = 1.0 * directionSign();
141 return result;
142 }
143
145 GridIndexType insideScvIdx() const
146 { return globalScvIndices_[0]; }
147
149 GridIndexType outsideScvIdx() const
150 { return globalScvIndices_[1]; }
151
152 GridIndexType index() const
153 { return globalScvfIdx_; }
154
155 SmallLocalIndexType localIndex() const
156 { return localScvfIdx_; }
157
159 { return faceType_; }
160
161 bool boundary() const
162 { return boundaryType_ == BoundaryType::physicalBoundary; }
163
164 bool processorBoundary() const
165 { return boundaryType_ == BoundaryType::processorBoundary; }
166
167 bool isFrontal() const
168 { return faceType_ == FaceType::frontal; }
169
170 bool isLateral() const
171 { return faceType_ == FaceType::lateral; }
172
173 Scalar area() const
174 { return area_; }
175
176 SmallLocalIndexType normalAxis() const
177 { return normalAxis_; }
178
179 std::int_least8_t directionSign() const
180 { return outerNormalSign_; }
181
182private:
183 GlobalPosition center_;
184 GlobalPosition ipGlobal_;
185 std::array<GridIndexType, 2> globalScvIndices_;
186 SmallLocalIndexType localScvfIdx_;
187 GridIndexType globalScvfIdx_;
188 Scalar area_;
189 SmallLocalIndexType normalAxis_;
190 std::int_least8_t outerNormalSign_;
191 FaceType faceType_;
192 BoundaryType boundaryType_;
193};
194
195} // end namespace Dumux
196
197#endif
Face centered staggered sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:54
BoundaryType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:72
SmallLocalIndexType normalAxis() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:176
const GlobalPosition unitOuterNormal() const
The unit outer normal.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:137
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:104
FaceType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:71
SmallLocalIndexType localIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:155
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:129
Scalar area() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:173
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:77
std::int_least8_t directionSign() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:179
GridIndexType outsideScvIdx() const
index of the outside sub control volume for spatial param evaluation
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:149
bool processorBoundary() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:164
const GlobalPosition & ipGlobal() const
The integration point of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:133
GridIndexType index() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:152
T Traits
state the traits public and thus export all types
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:68
bool isFrontal() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:167
GridIndexType insideScvIdx() const
Index of the inside sub control volume for spatial param evaluation.
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:145
typename T::GlobalPosition GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:70
bool isLateral() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:170
FaceType faceType() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:158
bool boundary() const
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:161
constexpr int sign(const ValueType &value) noexcept
Sign or signum function.
Definition: math.hh:629
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
Default traits class to be used for the sub-control volume face for the face-centered staggered finit...
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:35
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:36
std::array< GlobalPosition,(1<<(dim-1))> CornerStorage
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:44
static constexpr int dim
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:42
Dune::AxisAlignedCubeGeometry< Scalar, dim-1, dimWorld > Geometry
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:45
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:39
static constexpr int dimWorld
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:43
typename GridView::ctype Scalar
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:38
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:37
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolumeface.hh:40
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29
unsigned int LocalIndex
Definition: indextraits.hh:28
Base class for a sub control volume face.