version 3.8
discretization/staggered/freeflow/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_STAGGERED_FREE_FLOW_SUBCONTROLVOLUMEFACE_HH
13#define DUMUX_DISCRETIZATION_STAGGERED_FREE_FLOW_SUBCONTROLVOLUMEFACE_HH
14
15#include <array>
16#include <utility>
17#include <dune/common/fvector.hh>
18#include <dune/geometry/type.hh>
19#include <dune/geometry/multilineargeometry.hh>
20
25
26#include <typeinfo>
27
28namespace Dumux {
29
37template<class GridView, int upwindSchemeOrder>
39{
42 using Scalar = typename GridView::ctype;
46
47 using Grid = typename GridView::Grid;
48 static constexpr int dim = Grid::dimension;
49 static constexpr int dimWorld = Grid::dimensionworld;
50
51 using Element = typename GridView::template Codim<0>::Entity;
52 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
53 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim-1, dimWorld>;
54};
55
61template<class SubControlVolumeFace>
62SubControlVolumeFace makeStaggeredBoundaryFace(const SubControlVolumeFace& scvf,
63 const typename SubControlVolumeFace::GlobalPosition& newCenter)
64{
65 auto bf = scvf;
66 bf.setCenter(newCenter);
67 bf.setBoundary(true);
68 bf.setIsGhostFace(true);
69 return bf;
70}
71
77template<class GV,
78 int upwindSchemeOrder,
79 class T = FreeFlowStaggeredDefaultScvfGeometryTraits<GV, upwindSchemeOrder>>
81: public SubControlVolumeFaceBase<FreeFlowStaggeredSubControlVolumeFace<GV, upwindSchemeOrder, T>, T>
82{
85 using Geometry = typename T::Geometry;
86 using GridIndexType = typename IndexTraits<GV>::GridIndex;
87 using LocalIndexType = typename IndexTraits<GV>::LocalIndex;
88
89 using PairData = typename T::PairData;
90 using AxisData = typename T::AxisData;
91
92 using Scalar = typename T::Scalar;
93 static const int dim = GV::dimension;
94
95 static constexpr int numPairs = 2 * (dim - 1);
96
97 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
98
99public:
100 using GlobalPosition = typename T::GlobalPosition;
101
102 static constexpr int numCornersPerFace = 2 * (dim - 1);
103
105 using Traits = T;
106
107 // The default constructor
109
111 template <class Intersection>
113 const typename Intersection::Geometry& isGeometry,
114 GridIndexType scvfIndex,
115 const std::vector<GridIndexType>& scvIndices,
116 const typename T::GeometryHelper& geometryHelper)
117 : ParentType(),
118 area_(isGeometry.volume()),
119 center_(isGeometry.center()),
120 unitOuterNormal_(is.centerUnitOuterNormal()),
121 scvfIndex_(scvfIndex),
122 scvIndices_(scvIndices),
123 boundary_(is.boundary()),
124 axisData_(geometryHelper.axisData()),
125 pairData_(std::move(geometryHelper.pairData())),
126 localFaceIdx_(geometryHelper.localFaceIndex()),
127 dirIdx_(geometryHelper.directionIndex()),
128 outerNormalSign_(sign(unitOuterNormal_[directionIndex()])),
129 isGhostFace_(false)
130 {
131 dimensions[0] = (isGeometry.corner(1) - isGeometry.corner(0)).two_norm();
132 if constexpr (dim == 3)
133 dimensions[1] = (isGeometry.corner(2) - isGeometry.corner(0)).two_norm();
134 }
135
137 const GlobalPosition& center() const
138 {
139 return center_;
140 }
141
144 {
145 return center_;
146 }
147
150 {
151 // Return center for now
152 return center_;
153 }
154
156 Scalar area() const
157 {
158 return area_;
159 }
160
162 bool boundary() const
163 {
164 return boundary_;
165 }
166
169 {
170 return unitOuterNormal_;
171 }
172
174 GridIndexType insideScvIdx() const
175 {
176 return scvIndices_[0];
177 }
178
180 GridIndexType outsideScvIdx() const
181 {
182 return scvIndices_[1];
183 }
184
186 GridIndexType index() const
187 {
188 return scvfIndex_;
189 }
190
192 LocalIndexType localFaceIdx() const
193 {
194 return localFaceIdx_;
195 }
196
198 unsigned int directionIndex() const
199 {
200 return dirIdx_;
201 }
202
205 {
206 return directionSign() > 0;
207 }
208
210 int directionSign() const
211 {
212 return outerNormalSign_;
213 }
214
216 const PairData& pairData(const int idx) const
217 {
218 return pairData_[idx];
219 }
220
222 const std::array<PairData, numPairs>& pairData() const
223 {
224 return pairData_;
225 }
226
228 const AxisData& axisData() const
229 {
230 return axisData_;
231 }
232
234 bool isGhostFace() const
235 {
236 return isGhostFace_;
237 }
238
240 Scalar faceLength(const int localSubFaceIdx) const
241 {
242 if (dim == 3 && localSubFaceIdx > 1)
243 return dimensions[1];
244 else
245 return dimensions[0];
246 }
247
254 bool hasParallelNeighbor(const int localSubFaceIdx, const int parallelDegreeIdx) const
255 {
256 return pairData(localSubFaceIdx).hasParallelNeighbor[parallelDegreeIdx];
257 }
258
277 bool hasHalfParallelNeighbor(const int localSubFaceIdx) const
278 {
279 return pairData(localSubFaceIdx).hasHalfParallelNeighbor;
280 }
281
301 bool hasCornerParallelNeighbor(const int localSubFaceIdx) const
302 {
303 return pairData(localSubFaceIdx).hasCornerParallelNeighbor;
304 }
305
311 bool hasOuterLateral(const int localSubFaceIdx) const
312 {
313 return pairData(localSubFaceIdx).hasOuterLateral;
314 }
315
321 template<bool enable = useHigherOrder, std::enable_if_t<enable, int> = 0>
322 bool hasBackwardNeighbor(const int backwardIdx) const
323 {
324 return axisData().hasBackwardNeighbor[backwardIdx];
325 }
326
332 template<bool enable = useHigherOrder, std::enable_if_t<enable, int> = 0>
333 bool hasForwardNeighbor(const int forwardIdx) const
334 {
335 return axisData().hasForwardNeighbor[forwardIdx];
336 }
337
339 GridIndexType dofIndex() const
340 {
341 return axisData().selfDof;
342 }
343
345 GridIndexType dofIndexOpposingFace() const
346 {
347 return axisData().oppositeDof;
348 }
349
351 GridIndexType dofIndexForwardFace() const
352 {
353 return axisData().inAxisForwardDofs[0];
354 }
355
357 GridIndexType dofIndexBackwardFace() const
358 {
359 return axisData().inAxisBackwardDofs[0];
360 }
361
364 {
365 return axisData().selfToOppositeDistance;
366 }
367
374 Scalar parallelDofsDistance(const int localSubFaceIdx, const int parallelDegreeIdx) const
375 {
376 if (parallelDegreeIdx == 0)
377 return (faceLength(localSubFaceIdx) + pairData(localSubFaceIdx).parallelCellWidths[0]) * 0.5;
378 // pairData(localSubFaceIdx).parallelCellWidths[0]) will return 0.0 if the subface perpendicular the scvf lies on a boundary
379 else
380 {
381 assert((parallelDegreeIdx == 1) && "Only the width of the first two parallel cells (indices 0 and 1) is stored for each scvf.");
382 return (pairData(localSubFaceIdx).parallelCellWidths[0] + pairData(localSubFaceIdx).parallelCellWidths[1]) * 0.5;
383 }
384 }
385
388 { center_ = center; }
389
391 void setBoundary(bool boundaryFlag)
392 { boundary_ = boundaryFlag; }
393
395 void setIsGhostFace(bool isGhostFaceFlag)
396 { isGhostFace_ = isGhostFaceFlag; }
397
398private:
399 std::array<Scalar, dim-1> dimensions;
400 Scalar area_;
401 GlobalPosition center_;
402 GlobalPosition unitOuterNormal_;
403 GridIndexType scvfIndex_;
404 std::vector<GridIndexType> scvIndices_;
405 bool boundary_;
406
407 Scalar selfToOppositeDistance_;
408 AxisData axisData_;
409 std::array<PairData, numPairs> pairData_;
410
411 int localFaceIdx_;
412 unsigned int dirIdx_;
413 int outerNormalSign_;
414 bool isGhostFace_;
415};
416
417} // end namespace Dumux
418
419#endif
Helper class constructing the dual grid finite volume geometries for the free flow staggered discreti...
Definition: staggeredgeometryhelper.hh:134
Detail::AxisData< GridView, upwindSchemeOrder > AxisData
Definition: staggeredgeometryhelper.hh:154
Detail::PairData< GridView, upwindSchemeOrder > PairData
Definition: staggeredgeometryhelper.hh:153
Class for a sub control volume face in the staggered method, i.e a part of the boundary of a sub cont...
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:82
LocalIndexType localFaceIdx() const
The local index of this sub control volume face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:192
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:137
GridIndexType dofIndex() const
Returns the dof of the face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:339
void setBoundary(bool boundaryFlag)
set the boundary flag
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:391
const AxisData & axisData() const
Return an array of all pair data.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:228
bool hasOuterLateral(const int localSubFaceIdx) const
Check if the face has an outer normal neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:311
GridIndexType dofIndexForwardFace() const
Returns the dof the first forward face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:351
bool normalInPosCoordDir() const
Returns whether the unitNormal of the face points in positive coordinate direction.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:204
const std::array< PairData, numPairs > & pairData() const
Return an array of all pair data.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:222
GridIndexType dofIndexOpposingFace() const
Returns the dof of the opposing face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:345
Scalar parallelDofsDistance(const int localSubFaceIdx, const int parallelDegreeIdx) const
Returns the distance between the parallel dofs.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:374
Scalar selfToOppositeDistance() const
Returns the distance between the face and the opposite one.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:363
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:149
unsigned int directionIndex() const
Returns the direction index of the facet (0 = x, 1 = y, 2 = z)
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:198
bool isGhostFace() const
Returns true if the face is a ghost face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:234
const GlobalPosition & unitOuterNormal() const
The unit outer normal vector.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:168
bool hasHalfParallelNeighbor(const int localSubFaceIdx) const
Check if the face has a half parallel neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:277
void setIsGhostFace(bool isGhostFaceFlag)
set the ghost face flag
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:395
int directionSign() const
Returns the sign of the unit outer normal's vector.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:210
bool hasForwardNeighbor(const int forwardIdx) const
Check if the face has a forward neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:333
void setCenter(const GlobalPosition &center)
set the center to a different position
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:387
GridIndexType outsideScvIdx() const
index of the outside sub control volume for spatial param evaluation
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:180
static constexpr int numCornersPerFace
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:102
FreeFlowStaggeredSubControlVolumeFace(const Intersection &is, const typename Intersection::Geometry &isGeometry, GridIndexType scvfIndex, const std::vector< GridIndexType > &scvIndices, const typename T::GeometryHelper &geometryHelper)
Constructor with intersection.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:112
typename T::GlobalPosition GlobalPosition
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:100
bool hasBackwardNeighbor(const int backwardIdx) const
Check if the face has a backward neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:322
T Traits
State the traits public and thus export all types.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:105
bool boundary() const
Returns boolean if the sub control volume face is on the boundary.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:162
const PairData & pairData(const int idx) const
Returns the data for one sub face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:216
const GlobalPosition & dofPosition() const
The position of the dof living on the face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:143
GridIndexType index() const
The global index of this sub control volume face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:186
GridIndexType dofIndexBackwardFace() const
Returns the dof of the first backward face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:357
Scalar faceLength(const int localSubFaceIdx) const
Returns the length of the face in a certain direction (adaptation of area() for 3d)
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:240
Scalar area() const
The area of the sub control volume face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:156
bool hasParallelNeighbor(const int localSubFaceIdx, const int parallelDegreeIdx) const
Check if the face has a parallel neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:254
bool hasCornerParallelNeighbor(const int localSubFaceIdx) const
Check if the face has a corner parallel neighbor.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:301
GridIndexType insideScvIdx() const
Index of the inside sub control volume for spatial param evaluation.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:174
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
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
SubControlVolumeFace makeStaggeredBoundaryFace(const SubControlVolumeFace &scvf, const typename SubControlVolumeFace::GlobalPosition &newCenter)
Helper function to turn a given cell scvface into a fake boundary face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:62
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 faces for the free-flow staggered finite v...
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:39
static constexpr int dimWorld
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:49
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:40
static constexpr int dim
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:48
typename GridView::Grid Grid
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:47
typename GeometryHelper::AxisData AxisData
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:45
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:52
typename GeometryHelper::PairData PairData
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:44
Dune::AxisAlignedCubeGeometry< Scalar, dim-1, dimWorld > Geometry
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:53
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:51
typename GridView::ctype Scalar
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:42
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:41
Structure to define the index types used for grid and local indices.
Definition: indextraits.hh:26
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Base class for a sub control volume face.