24#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
29#include <dune/grid/common/partitionset.hh>
30#include <dune/grid/common/gridenums.hh>
40template<
class Gr
idGeometry>
43 using GridView =
typename GridGeometry::GridView;
45 using Stencil = std::vector<GridIndexType>;
46 using Map = std::vector<Stencil>;
51 void update(
const GridGeometry& gridGeometry)
54 map_.resize(gridGeometry.numScv());
56 auto fvGeometry =
localView(gridGeometry);
57 for (
const auto& element : elements(gridGeometry.gridView()))
59 if (element.partitionType() == Dune::InteriorEntity)
62 assert(element.partitionType() == Dune::OverlapEntity);
65 fvGeometry.bind(element);
67 for (
const auto& scvf : scvfs(fvGeometry))
69 if (scvf.isFrontal() && !scvf.boundary() && !scvf.processorBoundary())
71 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
72 const auto& facet = element.template subEntity <1> (ownScv.indexInElement());
73 if (facet.partitionType() == Dune::BorderEntity)
74 map_[ownScv.index()].push_back(scvf.outsideScvIdx());
79 for (
const auto& element : elements(gridGeometry.gridView(), Dune::Partitions::interior))
81 fvGeometry.bind(element);
84 for (
const auto& scvf : scvfs(fvGeometry))
86 assert(!scvf.processorBoundary());
87 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
88 const auto ownDofIndex = ownScv.dofIndex();
89 const auto ownScvIndex = ownScv.index();
94 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
98 for (
const auto& scv : scvs(fvGeometry))
100 const auto otherDofIndex = scv.dofIndex();
101 if (ownDofIndex != otherDofIndex)
102 map_[scv.index()].push_back(ownScvIndex);
114 if (!scvf.boundary())
115 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
126 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
127 assert(orthogonalScvf.isLateral());
128 map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx());
129 if (!orthogonalScvf.boundary())
130 map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx());
136 for (
auto& stencil : map_)
138 std::sort(stencil.begin(), stencil.end());
139 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
143 const Stencil&
operator[] (
const GridIndexType globalI)
const
144 {
return map_[globalI]; }
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
Stores the dof indices corresponding to the neighboring scvs that contribute to the derivative calcul...
Definition: facecentered/staggered/connectivitymap.hh:42
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: facecentered/staggered/connectivitymap.hh:51
const Stencil & operator[](const GridIndexType globalI) const
Definition: facecentered/staggered/connectivitymap.hh:143