12#ifndef DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
13#define DUMUX_STAGGERED_FREEFLOW_CONNECTIVITY_MAP_HH
25template<
class Gr
idGeometry>
28 using GridView =
typename GridGeometry::GridView;
29 using FVElementGeometry =
typename GridGeometry::LocalView;
30 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
32 using Element =
typename GridView::template Codim<0>::Entity;
35 using CellCenterIdxType =
typename GridGeometry::DofTypeIndices::CellCenterIdx;
36 using FaceIdxType =
typename GridGeometry::DofTypeIndices::FaceIdx;
40 using Stencil = std::vector<GridIndexType>;
41 using Map = std::vector<Stencil>;
43 static constexpr SmallLocalIndex upwindSchemeOrder = GridGeometry::upwindSchemeOrder;
44 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
49 void update(
const GridGeometry& gridGeometry)
51 const auto numDofsCC = gridGeometry.gridView().size(0);
52 const auto numDofsFace = gridGeometry.gridView().size(1);
53 const auto numBoundaryFacets = gridGeometry.numBoundaryScvf();
56 cellCenterToCellCenterMap_ = Map(numDofsCC);
57 cellCenterToFaceMap_ = Map(numDofsCC);
58 faceToCellCenterMap_ = Map(2*numDofsFace - numBoundaryFacets);
59 faceToFaceMap_ = Map(2*numDofsFace - numBoundaryFacets);
62 auto fvGeometry =
localView(gridGeometry);
63 for(
auto&& element: elements(gridGeometry.gridView()))
66 fvGeometry.bindElement(element);
69 for (
auto&& scvf : scvfs(fvGeometry))
72 const auto dofIdxCellCenter = gridGeometry.elementMapper().index(element);
77 cellCenterToCellCenterMap_[dofIdxCellCenter].push_back(scvf.outsideScvIdx());
80 cellCenterToFaceMap_[dofIdxCellCenter].push_back(scvf.dofIndex());
83 const auto scvfIdx = scvf.index();
84 computeFaceToCellCenterStencil_(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf);
85 computeFaceToFaceStencil_(faceToFaceMap_[scvfIdx], fvGeometry, scvf);
91 const Stencil&
operator() (CellCenterIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
93 return cellCenterToCellCenterMap_[globalI];
97 const Stencil&
operator() (CellCenterIdxType, FaceIdxType,
const GridIndexType globalI)
const
99 return cellCenterToFaceMap_[globalI];
103 const Stencil&
operator() (FaceIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
105 return faceToCellCenterMap_[globalI];
109 const Stencil&
operator() (FaceIdxType, FaceIdxType,
const GridIndexType globalI)
const
111 return faceToFaceMap_[globalI];
121 void computeFaceToCellCenterStencil_(Stencil& stencil,
122 const FVElementGeometry& fvGeometry,
123 const SubControlVolumeFace& scvf)
125 const auto eIdx = scvf.insideScvIdx();
126 stencil.push_back(eIdx);
128 for (
const auto& data : scvf.pairData())
130 auto& lateralFace = fvGeometry.scvf(eIdx, data.localLateralFaceIdx);
131 if (!lateralFace.boundary())
133 const auto firstParallelElementDofIdx = lateralFace.outsideScvIdx();
134 stencil.push_back(firstParallelElementDofIdx);
143 void computeFaceToFaceStencil_(Stencil& stencil,
144 const FVElementGeometry& fvGeometry,
145 const SubControlVolumeFace& scvf)
147 stencil.push_back(scvf.axisData().oppositeDof);
148 addHigherOrderInAxisDofs_(scvf, stencil, std::integral_constant<bool, useHigherOrder>{});
150 for (
const auto& data : scvf.pairData())
153 stencil.push_back(data.lateralPair.first);
154 if (!scvf.boundary())
155 stencil.push_back(data.lateralPair.second);
158 for (SmallLocalIndex i = 0; i < upwindSchemeOrder; i++)
160 if (data.hasParallelNeighbor[i])
161 stencil.push_back(data.parallelDofs[i]);
166 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::false_type) {}
168 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::true_type)
170 for (SmallLocalIndex i = 0; i < upwindSchemeOrder - 1; i++)
172 if (scvf.hasBackwardNeighbor(i))
173 stencil.push_back(scvf.axisData().inAxisBackwardDofs[i]);
175 if (scvf.hasForwardNeighbor(i))
176 stencil.push_back(scvf.axisData().inAxisForwardDofs[i]);
180 Map cellCenterToCellCenterMap_;
181 Map cellCenterToFaceMap_;
182 Map faceToCellCenterMap_;
Stores the dof indices corresponding to the neighboring cell centers and faces that contribute to the...
Definition: staggered/freeflow/connectivitymap.hh:27
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: staggered/freeflow/connectivitymap.hh:49
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:91
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29