11#ifndef DUMUX_INTERSECTIONITERATOR_HH 
   12#define DUMUX_INTERSECTIONITERATOR_HH 
   15#include <unordered_map> 
   17#include <dune/grid/common/mcmgmapper.hh> 
   18#include <dune/grid/common/rangegenerators.hh> 
   27template<
class Gr
idView>
 
   30    using Element = 
typename GridView::template Codim<0>::Entity;
 
   31    using GridIndexType = 
typename GridView::IndexSet::IndexType;
 
   33    static constexpr int codimIntersection =  1;
 
   38    , indexSet_(&gridView.indexSet())
 
 
   41    void update (
const GridView& gridView)
 
   44        indexSet_ = &gridView_.indexSet();
 
 
   49        gridView_ = std::move(gridView);
 
   50        indexSet_ = &gridView_.indexSet();
 
 
   56        return gridView_.size(1);
 
 
   64    std::size_t 
numFaces(
const Element& element)
 const 
   66        return element.subEntities(1);
 
 
   71        return indexSet_->subIndex(element, localFaceIdx, codimIntersection);
 
 
   76    const typename GridView::IndexSet* indexSet_;
 
 
   84template<
class Gr
idView>
 
   87    using Element = 
typename GridView::template Codim<0>::Entity;
 
   88    using Intersection = 
typename GridView::Intersection;
 
   89    using GridIndexType = 
typename GridView::IndexSet::IndexType;
 
   93    : gridView_(gridview),
 
   94      indexSet_(&gridView_.indexSet()),
 
   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        gridView_ = gridView;
 
  120        indexSet_ = &gridView_.indexSet();
 
 
  126        gridView_ = std::move(gridView);
 
  127        indexSet_ = &gridView_.indexSet();
 
 
  132    GridIndexType index(
const Element& element)
 const 
  134        return indexSet_->index(element);
 
  139        intersectionMapGlobal_.clear();
 
  140        intersectionMapGlobal_.resize(gridView_.size(0));
 
  142        int globalIntersectionIdx = 0;
 
  143        for (
const auto& element : elements(gridView_))
 
  145            int eIdx = index(element);
 
  149            for (
const auto& intersection : intersections(gridView_, element))
 
  151                if (intersection.neighbor())
 
  153                    auto neighbor = intersection.outside();
 
  154                    int eIdxN = index(neighbor);
 
  156                    if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdx < eIdxN))
 
  159                        for (
const auto& intersectionNeighbor : intersections(gridView_, neighbor))
 
  161                            if (intersectionNeighbor.neighbor())
 
  163                                if (intersectionNeighbor.outside() == element)
 
  170                        intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
 
  171                        intersectionMapGlobal_[eIdxN][fIdxN] = globalIntersectionIdx;
 
  172                        globalIntersectionIdx++;
 
  177                    intersectionMapGlobal_[eIdx][fIdx] = globalIntersectionIdx;
 
  178                    globalIntersectionIdx++;
 
  184        numIntersections_ = globalIntersectionIdx;
 
  188    const typename GridView::IndexSet* indexSet_;
 
  189    unsigned int numIntersections_;
 
  190    std::vector<std::unordered_map<int, int> > intersectionMapGlobal_;
 
 
  198template<
class Gr
idView>
 
  201    using Grid = 
typename GridView::Grid;
 
  202    enum {dim=Grid::dimension};
 
  203    using Element = 
typename Grid::template Codim<0>::Entity;
 
  204    using Intersection = 
typename GridView::Intersection;
 
  205    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
 
  215        const auto element = *
gridView_.template begin<0>();
 
  218        for (
const auto& intersection : intersections(
gridView_, element))
 
  220            int idxInInside = intersection.indexInInside();
 
 
  239    int index(
const Element& element)
 const 
 
  280    int subIndex(
const Element& element, 
int fIdx)
 const 
 
  301    int maplocal(
const Element& element, 
int fIdx)
 const 
 
  312    unsigned int size (
int elemIdx)
 const 
 
  317    unsigned int size (
const Element& element)
 const 
 
  344        for (
const auto& element : elements(
gridView_))
 
  346            int eIdxGlobal = 
index(element);
 
  350            for (
const auto& intersection : intersections(
gridView_, element))
 
  352                int indexInInside = intersection.indexInInside();
 
  358        int globalIntersectionIdx = 0;
 
  359        for (
const auto& element : elements(
gridView_))
 
  361            int eIdxGlobal = 
index(element);
 
  365            for (
const auto& intersection : intersections(
gridView_, element))
 
  367                if (intersection.neighbor())
 
  369                    auto neighbor = intersection.outside();
 
  370                    int globalIdxNeighbor = 
index(neighbor);
 
  372                    if (element.level() > neighbor.level() || (element.level() == neighbor.level() && eIdxGlobal < globalIdxNeighbor))
 
  375                        int faceIdxNeighbor = 0;
 
  376                        if (
size(globalIdxNeighbor) == 2 * dim)
 
  382                            for (
const auto& intersectionNeighbor : intersections(
gridView_, neighbor))
 
  384                                if (intersectionNeighbor.neighbor())
 
  386                                    if (intersectionNeighbor.outside() == element)
 
  397                        globalIntersectionIdx ++;
 
  403                    globalIntersectionIdx ++;
 
  408        size_ = globalIntersectionIdx;
 
 
 
int maplocal(const Element &element, int fIdx)
Definition intersectionmapper.hh:296
unsigned int size_
Definition intersectionmapper.hh:412
int subIndex(const Element &element, int fIdx) const
Definition intersectionmapper.hh:280
unsigned int size(int elemIdx) const
Definition intersectionmapper.hh:312
int subIndex(const Element &element, int fIdx)
Map interface fIdx'th interface of element to array index.
Definition intersectionmapper.hh:275
int subIndex(int elemIdx, int fIdx) const
Map interface fIdx'th interface of element index to array index.
Definition intersectionmapper.hh:263
int subIndex(int elemIdx, int fIdx)
Map interface fIdx'th interface of element index to array index.
Definition intersectionmapper.hh:251
std::unordered_map< int, int > standardLocalIdxMap_
Definition intersectionmapper.hh:415
int maplocal(const Element &element, int fIdx) const
Definition intersectionmapper.hh:301
std::vector< std::unordered_map< int, int > > intersectionMapLocal_
Definition intersectionmapper.hh:414
void update_()
Definition intersectionmapper.hh:335
void update(const GridView &gridView)
Definition intersectionmapper.hh:322
void update(GridView &&gridView)
Definition intersectionmapper.hh:328
unsigned int size() const
Definition intersectionmapper.hh:307
const ElementMapper & elementMapper() const
Definition intersectionmapper.hh:228
int maplocal(int elemIdx, int fIdx)
Definition intersectionmapper.hh:285
int maplocal(int elemIdx, int fIdx) const
Definition intersectionmapper.hh:290
unsigned int size(const Element &element) const
Definition intersectionmapper.hh:317
int index(const Element &element) const
Map element to array index.
Definition intersectionmapper.hh:239
IntersectionMapper(const GridView &gridview)
Definition intersectionmapper.hh:208
ElementMapper elementMapper_
Definition intersectionmapper.hh:411
GridView gridView_
Definition intersectionmapper.hh:410
std::vector< std::unordered_map< int, int > > intersectionMapGlobal_
Definition intersectionmapper.hh:413
Definition common/pdesolver.hh:24