12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_CONNECTIVITY_MAP_HH
17#include <dune/grid/common/partitionset.hh>
18#include <dune/grid/common/gridenums.hh>
28template<
class Gr
idGeometry>
31 using GridView =
typename GridGeometry::GridView;
33 using Stencil = std::vector<GridIndexType>;
34 using Map = std::vector<Stencil>;
39 void update(
const GridGeometry& gridGeometry)
42 map_.resize(gridGeometry.numScv());
44 auto fvGeometry =
localView(gridGeometry);
45 for (
const auto& element : elements(gridGeometry.gridView()))
47 if (element.partitionType() == Dune::InteriorEntity)
50 assert(element.partitionType() == Dune::OverlapEntity);
53 fvGeometry.bind(element);
55 for (
const auto& scvf : scvfs(fvGeometry))
57 if (scvf.isFrontal() && !scvf.boundary() && !scvf.processorBoundary())
59 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
60 const auto& facet = element.template subEntity <1> (ownScv.indexInElement());
61 if (facet.partitionType() == Dune::BorderEntity)
62 map_[ownScv.index()].push_back(scvf.outsideScvIdx());
67 for (
const auto& element : elements(gridGeometry.gridView(), Dune::Partitions::interior))
69 fvGeometry.bind(element);
72 for (
const auto& scvf : scvfs(fvGeometry))
74 assert(!scvf.processorBoundary());
75 const auto& ownScv = fvGeometry.scv(scvf.insideScvIdx());
76 const auto ownDofIndex = ownScv.dofIndex();
77 const auto ownScvIndex = ownScv.index();
82 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
86 for (
const auto& scv : scvs(fvGeometry))
88 const auto otherDofIndex = scv.dofIndex();
89 if (ownDofIndex != otherDofIndex)
90 map_[scv.index()].push_back(ownScvIndex);
102 if (!scvf.boundary())
103 map_[ownScvIndex].push_back(scvf.outsideScvIdx());
114 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
115 assert(orthogonalScvf.isLateral());
116 map_[ownScvIndex].push_back(orthogonalScvf.insideScvIdx());
117 if (!orthogonalScvf.boundary())
118 map_[ownScvIndex].push_back(orthogonalScvf.outsideScvIdx());
124 for (
auto& stencil : map_)
126 std::sort(stencil.begin(), stencil.end());
127 stencil.erase(std::unique(stencil.begin(), stencil.end()), stencil.end());
131 const Stencil&
operator[] (
const GridIndexType globalI)
const
132 {
return map_[globalI]; }
Stores the dof indices corresponding to the neighboring scvs that contribute to the derivative calcul...
Definition: facecentered/staggered/connectivitymap.hh:30
void update(const GridGeometry &gridGeometry)
Update the map and prepare the stencils.
Definition: facecentered/staggered/connectivitymap.hh:39
const Stencil & operator[](const GridIndexType globalI) const
Definition: facecentered/staggered/connectivitymap.hh:131
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