24#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GEOMETRY_HELPER_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_GEOMETRY_HELPER_HH
29#include <dune/common/exceptions.hh>
35template<
class Gr
idView>
40 using Element =
typename GridView::template Codim<0>::Entity;
41 using Facet =
typename GridView::template Codim<1>::Entity;
44 static constexpr auto dim = GridView::Grid::dimension;
51 static constexpr SmallLocalIndexType
localOppositeIdx(
const SmallLocalIndexType ownLocalFaceIndex)
53 return isOdd_(ownLocalFaceIndex) ? (ownLocalFaceIndex - 1) : (ownLocalFaceIndex + 1);
59 if constexpr(GridView::Grid::dimension == 1)
61 assert(
false &&
"There are no lateral scvfs in 1D");
65 if constexpr (GridView::Grid::dimension == 2)
67 switch (ownLocalScvfIndex)
79 assert(
false &&
"No lateral orthogonal scvf found");
86 switch (ownLocalScvfIndex)
115 assert(
false &&
"No lateral orthogonal scvf found");
125 constexpr auto table = []
127 using Table = std::array<std::array<SmallLocalIndexType, numLateralFacesPerScv>,
numElementFaces>;
128 if constexpr (
dim == 1)
130 else if constexpr (
dim == 2)
131 return Table {{ {2,3}, {2,3}, {0,1}, {0,1} }};
133 return Table {{ {2,3,4,5}, {2,3,4,5}, {0,1,4,5}, {0,1,4,5}, {0,1,2,3}, {0,1,2,3} }};
136 return table[ownLocalFaceIndex];
140 static Facet
facet(
const SmallLocalIndexType localFacetIdx,
const Element& element)
142 return element.template subEntity <1> (localFacetIdx);
146 auto intersection(
const SmallLocalIndexType localFacetIdx,
const Element& element)
const
153 DUNE_THROW(Dune::InvalidStateException,
"localFacetIdx " << localFacetIdx <<
" out of range");
157 template<
class FVElementGeometry,
class SubControlVolumeFace>
160 assert (scvf.isLateral());
162 using Grid =
typename FVElementGeometry::GridGeometry::Grid;
170 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
171 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
172 int onBoundaryCounter = 0;
173 onBoundaryCounter +=
static_cast<int>(insideScv.boundary());
174 onBoundaryCounter +=
static_cast<int>(outsideScv.boundary());
175 return onBoundaryCounter == 1;
179 template<
class SubControlVolumeFace,
class SubControlVolume>
181 const SubControlVolume& scv)
185 const SmallLocalIndexType offset = (
dim == 2) ? 3 : 5;
188 return isOdd_(scv.indexInElement()) ? scvf.localIndex() - offset : scvf.localIndex() + offset;
191 template<
class FVElementGeometry,
class SubControlVolumeFace>
192 [[deprecated(
"The interface outsideScvfWithSameIntegrationPoint() is deprecated and the function is moved to the FVElementGeometry. Use the new interface localIndexOutsideScvfWithSameIntegrationPoint() instead. Will be removed after 3.5")]]
195 const auto& lateralOrthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
196 assert(!lateralOrthogonalScvf.boundary());
198 const int offset = (
dim == 2) ? 3 : 5;
199 const auto otherLocalIdx = isOdd_(scvf.localIndex()) ? scvf.localIndex() - offset : scvf.localIndex() + offset;
201 auto outsideFVGeometry =
localView(fvGeometry.gridGeometry());
202 const auto outsideElementIdx = fvGeometry.scv(lateralOrthogonalScvf.outsideScvIdx()).elementIndex();
203 outsideFVGeometry.bindElement(fvGeometry.gridGeometry().element(outsideElementIdx));
205 for (
const auto& otherScvf : scvfs(outsideFVGeometry))
207 if (otherScvf.localIndex() == otherLocalIdx)
211 DUNE_THROW(Dune::InvalidStateException,
"No outside scvf found");
215 {
return gridView_; }
219 static constexpr bool isOdd_(
int number)
220 {
return number % 2; }
Defines the index types used for grid and local indices.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:41
Definition: discretization/facecentered/staggered/geometryhelper.hh:37
static Facet facet(const SmallLocalIndexType localFacetIdx, const Element &element)
Returns an element's facet based on the local facet index.
Definition: discretization/facecentered/staggered/geometryhelper.hh:140
static constexpr auto localLaterFaceIndices(const SmallLocalIndexType ownLocalFaceIndex)
Returns the local indices of the faces lateral to the own one.
Definition: discretization/facecentered/staggered/geometryhelper.hh:123
static bool scvfIntegrationPointInConcaveCorner(const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf)
Returns true if the IP of an scvf lies on a concave corner.
Definition: discretization/facecentered/staggered/geometryhelper.hh:158
static constexpr SmallLocalIndexType localOppositeIdx(const SmallLocalIndexType ownLocalFaceIndex)
Returns the local index of the opposing face.
Definition: discretization/facecentered/staggered/geometryhelper.hh:51
static constexpr auto numLateralFacesPerScv
Definition: discretization/facecentered/staggered/geometryhelper.hh:46
const GridView & gridView() const
Definition: discretization/facecentered/staggered/geometryhelper.hh:214
static constexpr auto numElementFaces
Definition: discretization/facecentered/staggered/geometryhelper.hh:45
FaceCenteredStaggeredGeometryHelper(const GridView &gridView)
Definition: discretization/facecentered/staggered/geometryhelper.hh:48
static SmallLocalIndexType localIndexOutsideScvfWithSameIntegrationPoint(const SubControlVolumeFace &scvf, const SubControlVolume &scv)
Definition: discretization/facecentered/staggered/geometryhelper.hh:180
auto intersection(const SmallLocalIndexType localFacetIdx, const Element &element) const
Returns an element's intersection based on the local facet index.
Definition: discretization/facecentered/staggered/geometryhelper.hh:146
static constexpr int lateralOrthogonalScvfLocalIndex(const SmallLocalIndexType ownLocalScvfIndex)
Return the local index of a lateral orthogonal scvf.
Definition: discretization/facecentered/staggered/geometryhelper.hh:57
static constexpr auto dim
Definition: discretization/facecentered/staggered/geometryhelper.hh:44
static const SubControlVolumeFace & outsideScvfWithSameIntegrationPoint(const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf)
Definition: discretization/facecentered/staggered/geometryhelper.hh:193
Type trait to determine if a grid supports concave corners (e.g. by cutting out a hole from the domai...
Definition: gridsupportsconcavecorners.hh:43