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>
39template<
class Gr
idView>
42 using Element =
typename GridView::template Codim<0>::Entity;
43 using GridIndexType =
typename GridView::IndexSet::IndexType;
45 static constexpr int codimIntersection = 1;
50 , indexSet_(&gridView.indexSet())
53 void update (
const GridView& gridView)
56 indexSet_ = &gridView_.indexSet();
61 gridView_ = std::move(gridView);
62 indexSet_ = &gridView_.indexSet();
68 return gridView_.size(1);
76 std::size_t
numFaces(
const Element& element)
const
78 return element.subEntities(1);
83 return indexSet_->subIndex(element, localFaceIdx, codimIntersection);
88 const typename GridView::IndexSet* indexSet_;
96template<
class Gr
idView>
99 using Element =
typename GridView::template Codim<0>::Entity;
100 using Intersection =
typename GridView::Intersection;
101 using GridIndexType =
typename GridView::IndexSet::IndexType;
105 : gridView_(gridview),
106 indexSet_(&gridView_.indexSet()),
107 numIntersections_(gridView_.size(1)),
108 intersectionMapGlobal_(gridView_.size(0))
116 return numIntersections_;
121 return (intersectionMapGlobal_[index(element)].find(localFaceIdx))->second;
126 return intersectionMapGlobal_[index(element)].size();
131 gridView_ = gridView;
132 indexSet_ = &gridView_.indexSet();
138 gridView_ = std::move(gridView);
139 indexSet_ = &gridView_.indexSet();
144 GridIndexType index(
const Element& element)
const
146 return indexSet_->index(element);
151 intersectionMapGlobal_.clear();
152 intersectionMapGlobal_.resize(gridView_.size(0));
154 int globalIntersectionIdx = 0;
155 for (
const auto& element : elements(gridView_))
157 int eIdx = index(element);
161 for (
const auto& intersection : intersections(gridView_, element))
163 if (intersection.neighbor())
165 auto neighbor = intersection.outside();
166 int eIdxN = index(neighbor);
168 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdx < eIdxN))
171 for (
const auto& intersectionNeighbor : intersections(gridView_, neighbor))
173 if (intersectionNeighbor.neighbor())
175 if (intersectionNeighbor.outside() == element)
182 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
183 intersectionMapGlobal_[eIdxN][fIdxN] = globalIntersectionIdx;
184 globalIntersectionIdx++;
189 intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
190 globalIntersectionIdx++;
196 numIntersections_ = globalIntersectionIdx;
200 const typename GridView::IndexSet* indexSet_;
201 unsigned int numIntersections_;
202 std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
210template<
class Gr
idView>
213 using Grid =
typename GridView::Grid;
214 enum {dim=Grid::dimension};
215 using Element =
typename Grid::template Codim<0>::Entity;
216 using Intersection =
typename GridView::Intersection;
217 using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
227 const auto element = *
gridView_.template begin<0>();
230 for (
const auto& intersection : intersections(
gridView_, element))
232 int idxInInside = intersection.indexInInside();
251 int index(
const Element& element)
const
292 int subIndex(
const Element& element,
int fIdx)
const
313 int maplocal(
const Element& element,
int fIdx)
const
324 unsigned int size (
int elemIdx)
const
329 unsigned int size (
const Element& element)
const
356 for (
const auto& element : elements(
gridView_))
358 int eIdxGlobal =
index(element);
362 for (
const auto& intersection : intersections(
gridView_, element))
364 int indexInInside = intersection.indexInInside();
370 int globalIntersectionIdx = 0;
371 for (
const auto& element : elements(
gridView_))
373 int eIdxGlobal =
index(element);
377 for (
const auto& intersection : intersections(
gridView_, element))
379 if (intersection.neighbor())
381 auto neighbor = intersection.outside();
382 int globalIdxNeighbor =
index(neighbor);
384 if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdxGlobal < globalIdxNeighbor))
387 int faceIdxNeighbor = 0;
388 if (
size(globalIdxNeighbor) == 2 * dim)
394 for (
const auto& intersectionNeighbor : intersections(
gridView_, neighbor))
396 if (intersectionNeighbor.neighbor())
398 if (intersectionNeighbor.outside() == element)
409 globalIntersectionIdx ++;
415 globalIntersectionIdx ++;
420 size_ = globalIntersectionIdx;
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Definition: deprecated.hh:149
defines a standard intersection mapper for mapping of global DOFs assigned to faces....
Definition: intersectionmapper.hh:41
std::size_t numFaces(const Element &element) const
The number of faces for a given element.
Definition: intersectionmapper.hh:76
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:81
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:66
ConformingGridIntersectionMapper(const GridView &gridView)
Definition: intersectionmapper.hh:48
void update(const GridView &gridView)
Definition: intersectionmapper.hh:53
void update(GridView &&gridView)
Definition: intersectionmapper.hh:59
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for non-...
Definition: intersectionmapper.hh:98
std::size_t numFaces(const Element &element)
Definition: intersectionmapper.hh:124
std::size_t numIntersections() const
The total number of intersections.
Definition: intersectionmapper.hh:114
void update(const GridView &gridView)
Definition: intersectionmapper.hh:129
NonConformingGridIntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:104
void update(GridView &&gridView)
Definition: intersectionmapper.hh:136
GridIndexType globalIntersectionIndex(const Element &element, const std::size_t localFaceIdx) const
Definition: intersectionmapper.hh:119
defines an intersection mapper for mapping of global DOFs assigned to faces which also works for adap...
Definition: intersectionmapper.hh:212
int maplocal(const Element &element, int fIdx)
Definition: intersectionmapper.hh:308
unsigned int size_
Definition: intersectionmapper.hh:424
int subIndex(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:292
unsigned int size(int elemIdx) const
Definition: intersectionmapper.hh:324
int subIndex(const Element &element, int fIdx)
Map interface fIdx'th interface of element to array index.
Definition: intersectionmapper.hh:287
int subIndex(int elemIdx, int fIdx) const
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:275
int subIndex(int elemIdx, int fIdx)
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:263
std::unordered_map< int, int > standardLocalIdxMap_
Definition: intersectionmapper.hh:427
int maplocal(const Element &element, int fIdx) const
Definition: intersectionmapper.hh:313
std::vector< std::unordered_map< int, int > > intersectionMapLocal_
Definition: intersectionmapper.hh:426
void update_()
Definition: intersectionmapper.hh:347
void update(const GridView &gridView)
Definition: intersectionmapper.hh:334
void update(GridView &&gridView)
Definition: intersectionmapper.hh:340
unsigned int size() const
Definition: intersectionmapper.hh:319
const ElementMapper & elementMapper() const
Definition: intersectionmapper.hh:240
int maplocal(int elemIdx, int fIdx)
Definition: intersectionmapper.hh:297
int maplocal(int elemIdx, int fIdx) const
Definition: intersectionmapper.hh:302
unsigned int size(const Element &element) const
Definition: intersectionmapper.hh:329
int index(const Element &element) const
Map element to array index.
Definition: intersectionmapper.hh:251
IntersectionMapper(const GridView &gridview)
Definition: intersectionmapper.hh:220
ElementMapper elementMapper_
Definition: intersectionmapper.hh:423
GridView gridView_
Definition: intersectionmapper.hh:422
std::vector< std::unordered_map< int, int > > intersectionMapGlobal_
Definition: intersectionmapper.hh:425