23#ifndef DUMUX_INTERSECTIONITERATOR_HH
24#define DUMUX_INTERSECTIONITERATOR_HH
27#include <unordered_map>
29#include <dune/grid/common/mcmgmapper.hh>
30#include <dune/grid/common/rangegenerators.hh>
40template<
class Gr
idView>
43 using Element =
typename GridView::template Codim<0>::Entity;
44 using GridIndexType =
typename GridView::IndexSet::IndexType;
46 static constexpr int codimIntersection = 1;
50 : gridView_(gridView) { }
58 return gridView_.size(1);
66 std::size_t
numFaces(
const Element& element)
const
68 return element.subEntities(1);
73 return gridView_.indexSet().subIndex(element, localFaceIdx, codimIntersection);
77 const GridView gridView_;
85template<
class Gr
idView>
88 using Element =
typename GridView::template Codim<0>::Entity;
89 using Intersection =
typename GridView::Intersection;
90 using GridIndexType =
typename GridView::IndexSet::IndexType;
94 : gridView_(gridview),
95 numIntersections_(gridView_.size(1)),
96 intersectionMapGlobal_(gridView_.size(0))
104 return numIntersections_;
109 return (intersectionMapGlobal_[index(element)].find(localFaceIdx))->second;
114 return intersectionMapGlobal_[index(element)].size();
119 intersectionMapGlobal_.clear();
120 intersectionMapGlobal_.resize(gridView_.size(0));
122 int globalIntersectionIdx = 0;
123 for (
const auto& element : elements(gridView_))
125 int eIdx = index(element);
129 for (
const auto& intersection : intersections(gridView_, element))
131 if (intersection.neighbor())
133 auto neighbor = intersection.outside();
134 int eIdxN = index(neighbor);
136 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdx < eIdxN))
139 for (
const auto& intersectionNeighbor : intersections(gridView_, neighbor))
141 if (intersectionNeighbor.neighbor())
143 if (intersectionNeighbor.outside() == element)
150 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
151 intersectionMapGlobal_[eIdxN][fIdxN] = globalIntersectionIdx;
152 globalIntersectionIdx++;
157 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
158 globalIntersectionIdx++;
164 numIntersections_ = globalIntersectionIdx;
168 GridIndexType index(
const Element& element)
const
170 return gridView_.indexSet().index(element);
173 const GridView gridView_;
174 unsigned int numIntersections_;
175 std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
183template<
class Gr
idView>
186 using Grid =
typename GridView::Grid;
187 enum {dim=Grid::dimension};
188 using Element =
typename Grid::template Codim<0>::Entity;
189 using Intersection =
typename GridView::Intersection;
190 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
200 const auto element = *
gridView_.template begin<0>();
203 for (
const auto& intersection : intersections(
gridView_, element))
205 int idxInInside = intersection.indexInInside();
224 int index(
const Element& element)
const
265 int subIndex(
const Element& element,
int fIdx)
const
286 int maplocal(
const Element& element,
int fIdx)
const
297 unsigned int size (
int elemIdx)
const
302 unsigned int size (
const Element& element)
const
316 for (
const auto& element : elements(
gridView_))
318 int eIdxGlobal =
index(element);
322 for (
const auto& intersection : intersections(
gridView_, element))
324 int indexInInside = intersection.indexInInside();
331 int globalIntersectionIdx = 0;
332 for (
const auto& element : elements(
gridView_))
334 int eIdxGlobal =
index(element);
338 for (
const auto& intersection : intersections(
gridView_, element))
340 if (intersection.neighbor())
342 auto neighbor = intersection.outside();
343 int globalIdxNeighbor =
index(neighbor);
345 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdxGlobal < globalIdxNeighbor))
348 int faceIdxNeighbor = 0;
349 if (
size(globalIdxNeighbor) == 2 * dim)
355 for (
const auto& intersectionNeighbor : intersections(
gridView_, neighbor))
357 if (intersectionNeighbor.neighbor())
359 if (intersectionNeighbor.outside() == element)
370 globalIntersectionIdx ++;
376 globalIntersectionIdx ++;
381 size_ = globalIntersectionIdx;
Definition: common/pdesolver.hh:35
defines a standard intersection mapper for mapping of global DOFs assigned to faces....
Definition: intersectionmapper.hh:42
std::size_t numFaces(const Element &element) const
The number of faces for a given element.
Definition: intersectionmapper.hh:66
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:71
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:56
ConformingGridIntersectionMapper(const GridView &gridView)
Definition: intersectionmapper.hh:49
void update()
Definition: intersectionmapper.hh:52
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for non-...
Definition: intersectionmapper.hh:87
std::size_t numFaces(const Element &element)
Definition: intersectionmapper.hh:112
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:102
NonConformingGridIntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:93
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:107
void update()
Definition: intersectionmapper.hh:117
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition: intersectionmapper.hh:185
int maplocal(const Element &element, int fIdx)
Definition: intersectionmapper.hh:281
unsigned int size_
Definition: intersectionmapper.hh:387
int subIndex(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:265
const GridView gridView_
Definition: intersectionmapper.hh:385
unsigned int size(int elemIdx) const
Definition: intersectionmapper.hh:297
int subIndex(const Element &element, int fIdx)
Map interface fIdx'th interface of element to array index.
Definition: intersectionmapper.hh:260
int subIndex(int elemIdx, int fIdx) const
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:248
int subIndex(int elemIdx, int fIdx)
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:236
std::unordered_map< int, int > standardLocalIdxMap_
Definition: intersectionmapper.hh:390
int maplocal(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:286
std::vector< std::unordered_map< int, int > > intersectionMapLocal_
Definition: intersectionmapper.hh:389
unsigned int size() const
Definition: intersectionmapper.hh:292
const ElementMapper & elementMapper() const
Definition: intersectionmapper.hh:213
int maplocal(int elemIdx, int fIdx)
Definition: intersectionmapper.hh:270
int maplocal(int elemIdx, int fIdx) const
Definition: intersectionmapper.hh:275
unsigned int size(const Element &element) const
Definition: intersectionmapper.hh:302
int index(const Element &element) const
Map element to array index.
Definition: intersectionmapper.hh:224
IntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:193
void update()
Definition: intersectionmapper.hh:307
ElementMapper elementMapper_
Definition: intersectionmapper.hh:386
std::vector< std::unordered_map< int, int > > intersectionMapGlobal_
Definition: intersectionmapper.hh:388