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>
41template<
class Gr
idView>
44 using Element =
typename GridView::template Codim<0>::Entity;
45 using GridIndexType =
typename GridView::IndexSet::IndexType;
47 static constexpr int codimIntersection = 1;
52 , indexSet_(&gridView.indexSet())
55 void update (
const GridView& gridView)
58 indexSet_ = &gridView_.indexSet();
63 gridView_ = std::move(gridView);
64 indexSet_ = &gridView_.indexSet();
67 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.4.")]]
74 return gridView_.size(1);
82 std::size_t
numFaces(
const Element& element)
const
84 return element.subEntities(1);
89 return indexSet_->subIndex(element, localFaceIdx, codimIntersection);
94 const typename GridView::IndexSet* indexSet_;
102template<
class Gr
idView>
105 using Element =
typename GridView::template Codim<0>::Entity;
106 using Intersection =
typename GridView::Intersection;
107 using GridIndexType =
typename GridView::IndexSet::IndexType;
111 : gridView_(gridview),
112 indexSet_(&gridView_.indexSet()),
113 numIntersections_(gridView_.size(1)),
114 intersectionMapGlobal_(gridView_.size(0))
122 return numIntersections_;
127 return (intersectionMapGlobal_[index(element)].find(localFaceIdx))->second;
132 return intersectionMapGlobal_[index(element)].size();
137 gridView_ = gridView;
138 indexSet_ = &gridView_.indexSet();
144 gridView_ = std::move(gridView);
145 indexSet_ = &gridView_.indexSet();
149 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.4.")]]
156 GridIndexType index(
const Element& element)
const
158 return indexSet_->index(element);
163 intersectionMapGlobal_.clear();
164 intersectionMapGlobal_.resize(gridView_.size(0));
166 int globalIntersectionIdx = 0;
167 for (
const auto& element : elements(gridView_))
169 int eIdx = index(element);
173 for (
const auto& intersection : intersections(gridView_, element))
175 if (intersection.neighbor())
177 auto neighbor = intersection.outside();
178 int eIdxN = index(neighbor);
180 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdx < eIdxN))
183 for (
const auto& intersectionNeighbor : intersections(gridView_, neighbor))
185 if (intersectionNeighbor.neighbor())
187 if (intersectionNeighbor.outside() == element)
194 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
195 intersectionMapGlobal_[eIdxN][fIdxN] = globalIntersectionIdx;
196 globalIntersectionIdx++;
201 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
202 globalIntersectionIdx++;
208 numIntersections_ = globalIntersectionIdx;
212 const typename GridView::IndexSet* indexSet_;
213 unsigned int numIntersections_;
214 std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
222template<
class Gr
idView>
225 using Grid =
typename GridView::Grid;
226 enum {dim=Grid::dimension};
227 using Element =
typename Grid::template Codim<0>::Entity;
228 using Intersection =
typename GridView::Intersection;
229 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
239 const auto element = *
gridView_.template begin<0>();
242 for (
const auto& intersection : intersections(
gridView_, element))
244 int idxInInside = intersection.indexInInside();
263 int index(
const Element& element)
const
304 int subIndex(
const Element& element,
int fIdx)
const
325 int maplocal(
const Element& element,
int fIdx)
const
336 unsigned int size (
int elemIdx)
const
341 unsigned int size (
const Element& element)
const
358 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.4.")]]
367 if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
377 for (
const auto& element : elements(
gridView_))
379 int eIdxGlobal =
index(element);
383 for (
const auto& intersection : intersections(
gridView_, element))
385 int indexInInside = intersection.indexInInside();
391 int globalIntersectionIdx = 0;
392 for (
const auto& element : elements(
gridView_))
394 int eIdxGlobal =
index(element);
398 for (
const auto& intersection : intersections(
gridView_, element))
400 if (intersection.neighbor())
402 auto neighbor = intersection.outside();
403 int globalIdxNeighbor =
index(neighbor);
405 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdxGlobal < globalIdxNeighbor))
408 int faceIdxNeighbor = 0;
409 if (
size(globalIdxNeighbor) == 2 * dim)
415 for (
const auto& intersectionNeighbor : intersections(
gridView_, neighbor))
417 if (intersectionNeighbor.neighbor())
419 if (intersectionNeighbor.outside() == element)
430 globalIntersectionIdx ++;
436 globalIntersectionIdx ++;
441 size_ = globalIntersectionIdx;
Definition: common/pdesolver.hh:36
defines a standard intersection mapper for mapping of global DOFs assigned to faces....
Definition: intersectionmapper.hh:43
std::size_t numFaces(const Element &element) const
The number of faces for a given element.
Definition: intersectionmapper.hh:82
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:87
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:72
ConformingGridIntersectionMapper(const GridView &gridView)
Definition: intersectionmapper.hh:50
void update()
Definition: intersectionmapper.hh:68
void update(const GridView &gridView)
Definition: intersectionmapper.hh:55
void update(GridView &&gridView)
Definition: intersectionmapper.hh:61
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for non-...
Definition: intersectionmapper.hh:104
std::size_t numFaces(const Element &element)
Definition: intersectionmapper.hh:130
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:120
void update(const GridView &gridView)
Definition: intersectionmapper.hh:135
NonConformingGridIntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:110
void update(GridView &&gridView)
Definition: intersectionmapper.hh:142
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:125
void update()
Definition: intersectionmapper.hh:150
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition: intersectionmapper.hh:224
int maplocal(const Element &element, int fIdx)
Definition: intersectionmapper.hh:320
unsigned int size_
Definition: intersectionmapper.hh:445
int subIndex(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:304
unsigned int size(int elemIdx) const
Definition: intersectionmapper.hh:336
int subIndex(const Element &element, int fIdx)
Map interface fIdx'th interface of element to array index.
Definition: intersectionmapper.hh:299
int subIndex(int elemIdx, int fIdx) const
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:287
int subIndex(int elemIdx, int fIdx)
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:275
std::unordered_map< int, int > standardLocalIdxMap_
Definition: intersectionmapper.hh:448
int maplocal(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:325
std::vector< std::unordered_map< int, int > > intersectionMapLocal_
Definition: intersectionmapper.hh:447
void update_()
Definition: intersectionmapper.hh:365
void update(const GridView &gridView)
Definition: intersectionmapper.hh:346
void update(GridView &&gridView)
Definition: intersectionmapper.hh:352
unsigned int size() const
Definition: intersectionmapper.hh:331
const ElementMapper & elementMapper() const
Definition: intersectionmapper.hh:252
int maplocal(int elemIdx, int fIdx)
Definition: intersectionmapper.hh:309
int maplocal(int elemIdx, int fIdx) const
Definition: intersectionmapper.hh:314
unsigned int size(const Element &element) const
Definition: intersectionmapper.hh:341
int index(const Element &element) const
Map element to array index.
Definition: intersectionmapper.hh:263
IntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:232
void update()
Definition: intersectionmapper.hh:359
ElementMapper elementMapper_
Definition: intersectionmapper.hh:444
GridView gridView_
Definition: intersectionmapper.hh:443
std::vector< std::unordered_map< int, int > > intersectionMapGlobal_
Definition: intersectionmapper.hh:446