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();
68 cellCenterToCellCenterMap_ = Map(numDofsCC);
69 cellCenterToFaceMap_ = Map(numDofsCC);
70 faceToCellCenterMap_ = Map(2*numDofsFace - numBoundaryFacets);
71 faceToFaceMap_ = Map(2*numDofsFace - numBoundaryFacets);
74 auto fvGeometry =
localView(gridGeometry);
75 for(
auto&& element: elements(gridGeometry.gridView()))
78 fvGeometry.bindElement(element);
81 for (
auto&& scvf : scvfs(fvGeometry))
84 const auto dofIdxCellCenter = gridGeometry.elementMapper().index(element);
89 cellCenterToCellCenterMap_[dofIdxCellCenter].push_back(scvf.outsideScvIdx());
92 cellCenterToFaceMap_[dofIdxCellCenter].push_back(scvf.dofIndex());
95 const auto scvfIdx = scvf.index();
96 computeFaceToCellCenterStencil_(faceToCellCenterMap_[scvfIdx], fvGeometry, scvf);
97 computeFaceToFaceStencil_(faceToFaceMap_[scvfIdx], fvGeometry, scvf);
103 const Stencil&
operator() (CellCenterIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
105 return cellCenterToCellCenterMap_[globalI];
109 const Stencil&
operator() (CellCenterIdxType, FaceIdxType,
const GridIndexType globalI)
const
111 return cellCenterToFaceMap_[globalI];
115 const Stencil&
operator() (FaceIdxType, CellCenterIdxType,
const GridIndexType globalI)
const
117 return faceToCellCenterMap_[globalI];
121 const Stencil&
operator() (FaceIdxType, FaceIdxType,
const GridIndexType globalI)
const
123 return faceToFaceMap_[globalI];
133 void computeFaceToCellCenterStencil_(Stencil& stencil,
134 const FVElementGeometry& fvGeometry,
135 const SubControlVolumeFace& scvf)
137 const auto eIdx = scvf.insideScvIdx();
138 stencil.push_back(eIdx);
140 for (
const auto& data : scvf.pairData())
142 auto& lateralFace = fvGeometry.scvf(eIdx, data.localLateralFaceIdx);
143 if (!lateralFace.boundary())
145 const auto firstParallelElementDofIdx = lateralFace.outsideScvIdx();
146 stencil.push_back(firstParallelElementDofIdx);
155 void computeFaceToFaceStencil_(Stencil& stencil,
156 const FVElementGeometry& fvGeometry,
157 const SubControlVolumeFace& scvf)
159 stencil.push_back(scvf.axisData().oppositeDof);
160 addHigherOrderInAxisDofs_(scvf, stencil, std::integral_constant<bool, useHigherOrder>{});
162 for (
const auto& data : scvf.pairData())
165 stencil.push_back(data.lateralPair.first);
166 if (!scvf.boundary())
167 stencil.push_back(data.lateralPair.second);
170 for (SmallLocalIndex i = 0; i < upwindSchemeOrder; i++)
172 if (data.hasParallelNeighbor[i])
173 stencil.push_back(data.parallelDofs[i]);
178 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::false_type) {}
180 void addHigherOrderInAxisDofs_(
const SubControlVolumeFace& scvf, Stencil& stencil, std::true_type)
182 for (SmallLocalIndex i = 0; i < upwindSchemeOrder - 1; i++)
184 if (scvf.hasBackwardNeighbor(i))
185 stencil.push_back(scvf.axisData().inAxisBackwardDofs[i]);
187 if (scvf.hasForwardNeighbor(i))
188 stencil.push_back(scvf.axisData().inAxisForwardDofs[i]);
192 Map cellCenterToCellCenterMap_;
193 Map cellCenterToFaceMap_;
194 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
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:103