24#ifndef DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
25#define DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
37template<
class Gr
idGeometry>
40 using GridView =
typename GridGeometry::GridView;
41 using FVElementGeometry =
typename GridGeometry::LocalView;
42 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
44 using Element =
typename GridView::template Codim<0>::Entity;
47 using CellCenterIdxType =
typename GridGeometry::DofTypeIndices::CellCenterIdx;
48 using FaceIdxType =
typename GridGeometry::DofTypeIndices::FaceIdx;
52 using Stencil = std::vector<GridIndexType>;
53 using Map = std::vector<Stencil>;
55 static constexpr SmallLocalIndex upwindSchemeOrder = GridGeometry::upwindSchemeOrder;
56 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
61 void update(
const GridGeometry& gridGeometry)
63 const auto numDofsCC = gridGeometry.gridView().size(0);
64 const auto numDofsFace = gridGeometry.gridView().size(1);
65 const auto numBoundaryFacets = gridGeometry.numBoundaryScvf();
66 cellCenterToCellCenterMap_.resize(numDofsCC);
67 cellCenterToFaceMap_.resize(numDofsCC);
68 faceToCellCenterMap_.resize(2*numDofsFace - numBoundaryFacets);
69 faceToFaceMap_.resize(2*numDofsFace - numBoundaryFacets);
71 for(
auto&& element: elements(gridGeometry.gridView()))
74 auto fvGeometry =
localView(gridGeometry);
75 fvGeometry.bindElement(element);
78 for (
auto&& scvf : scvfs(fvGeometry))
81 const auto dofIdxCellCenter = gridGeometry.elementMapper().index(element);
86 cellCenterToCellCenterMap_[dofIdxCellCenter].push_back(scvf.outsideScvIdx());
89 cellCenterToFaceMap_[dofIdxCellCenter].push_back(scvf.dofIndex());
92 const auto scvfIdx = scvf.index();
93 computeFaceToCellCenterStencil_(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf);
94 computeFaceToFaceStencil_(faceToFaceMap_[scvfIdx], fvGeometry, scvf);
100 const Stencil&
operator() (CellCenterIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
102 return cellCenterToCellCenterMap_[globalI];
106 const Stencil&
operator() (CellCenterIdxType, FaceIdxType,
const GridIndexType globalI)
const
108 return cellCenterToFaceMap_[globalI];
112 const Stencil&
operator() (FaceIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
114 return faceToCellCenterMap_[globalI];
118 const Stencil&
operator() (FaceIdxType, FaceIdxType,
const GridIndexType globalI)
const
120 return faceToFaceMap_[globalI];
130 void computeFaceToCellCenterStencil_(Stencil& stencil,
131 const FVElementGeometry& fvGeometry,
132 const SubControlVolumeFace& scvf)
134 const auto eIdx = scvf.insideScvIdx();
135 stencil.push_back(eIdx);
137 for (
const auto& data : scvf.pairData())
139 auto& lateralFace = fvGeometry.scvf(eIdx, data.localLateralFaceIdx);
140 if (!lateralFace.boundary())
142 const auto firstParallelElementDofIdx = lateralFace.outsideScvIdx();
143 stencil.push_back(firstParallelElementDofIdx);
152 void computeFaceToFaceStencil_(Stencil& stencil,
153 const FVElementGeometry& fvGeometry,
154 const SubControlVolumeFace& scvf)
156 stencil.push_back(scvf.axisData().oppositeDof);
157 addHigherOrderInAxisDofs_(scvf, stencil, std::integral_constant<bool, useHigherOrder>{});
159 for (
const auto& data : scvf.pairData())
162 stencil.push_back(data.lateralPair.first);
163 if (!scvf.boundary())
164 stencil.push_back(data.lateralPair.second);
167 for (SmallLocalIndex i = 0; i < upwindSchemeOrder; i++)
169 if (data.hasParallelNeighbor[i])
170 stencil.push_back(data.parallelDofs[i]);
175 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::false_type) {}
177 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::true_type)
179 for (SmallLocalIndex i = 0; i < upwindSchemeOrder - 1; i++)
181 if (scvf.hasBackwardNeighbor(i))
182 stencil.push_back(scvf.axisData().inAxisBackwardDofs[i]);
184 if (scvf.hasForwardNeighbor(i))
185 stencil.push_back(scvf.axisData().inAxisForwardDofs[i]);
189 Map cellCenterToCellCenterMap_;
190 Map cellCenterToFaceMap_;
191 Map faceToCellCenterMap_;
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
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:41
Stores the dof indices corresponding to the neighboring cell centers and faces that contribute to the...
Definition: staggered/freeflow/connectivitymap.hh:39
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: staggered/freeflow/connectivitymap.hh:61
const Stencil & operator()(CellCenterIdxType, CellCenterIdxType, const GridIndexType globalI) const
Returns the stencil of a cell center dof w.r.t. other cell center dofs.
Definition: staggered/freeflow/connectivitymap.hh:100