Loading [MathJax]/extensions/tex2jax.js

dune-mmesh (unstable)

intersectioniterator.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_MMESH_GRID_INTERSECTIONITERATOR_HH
4#define DUNE_MMESH_GRID_INTERSECTIONITERATOR_HH
5
10// Dune includes
11#include <dune/grid/common/intersection.hh>
12
13// Dune MMesh includes
16
17namespace Dune {
18
27template <class GridImp>
29 enum { dim = GridImp::dimension };
30
31 enum { dimworld = GridImp::dimensionworld };
32
33 // The type used to store coordinates
34 typedef typename GridImp::ctype ctype;
35
36 typedef typename GridImp::template HostGridEntity<0> HostGridEntity;
37
38 public:
39 typedef Dune::Intersection<const GridImp,
41 Intersection;
42
45
47 MMeshLeafIntersectionIterator(const GridImp* mMesh,
48 const HostGridEntity& hostEntity)
49 : mMesh_(mMesh), hostEntity_(hostEntity), i_(0) {
50 while (proceed()) increment();
51 }
52
54 MMeshLeafIntersectionIterator(const GridImp* mMesh,
55 const HostGridEntity& hostEntity, bool endDummy)
56 : mMesh_(mMesh), hostEntity_(hostEntity), i_(dim + 1) {}
57
59 bool equals(const MMeshLeafIntersectionIterator& other) const {
60 return i_ == other.i_ && hostEntity_ == other.hostEntity_;
61 }
62
64 void increment() {
65 do {
66 ++i_;
67 } while (proceed());
68 }
69
71 Intersection dereference() const {
72 // remark: the i-th intersection in CGAL corresponds to the (dim-i)-th edge
73 // in DUNE
74 return MMeshLeafIntersection<GridImp>(mMesh_, hostEntity_, dim - i_);
75 }
76
77 private:
79 bool proceed() {
80 if (i_ == dim + 1) return false;
81
82 // on ghosts return intersection only if adjacent entity is interior
83 if (hostEntity_->info().partition == 2) {
84 const auto& neighborHostEntity = hostEntity_->neighbor(dim - i_);
85
86 if (mMesh_->getHostGrid().is_infinite(neighborHostEntity)) return true;
87
88 // skip ghost neighbors
89 if (neighborHostEntity->info().partition != 0) return true;
90 }
91 return false;
92 }
93
94 const GridImp* mMesh_;
95 HostGridEntity hostEntity_;
96 int i_;
97};
98
99} // namespace Dune
100
101#endif
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: intersectioniterator.hh:28
MMeshLeafIntersectionIterator(const GridImp *mMesh, const HostGridEntity &hostEntity)
constructor for (begin) iterator
Definition: intersectioniterator.hh:47
MMeshLeafIntersectionIterator(const GridImp *mMesh, const HostGridEntity &hostEntity, bool endDummy)
constructor for end iterator
Definition: intersectioniterator.hh:54
void increment()
prefix increment
Definition: intersectioniterator.hh:64
MMeshLeafIntersectionIterator()
default constructor
Definition: intersectioniterator.hh:44
Intersection dereference() const
dereferencing
Definition: intersectioniterator.hh:71
bool equals(const MMeshLeafIntersectionIterator &other) const
returns if iterators reference same intersection
Definition: intersectioniterator.hh:59
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: intersections.hh:35
The MMeshEntity class.
The MMeshLeafIntersection and MMeshLevelIntersection classes.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 16, 23:47, 2025)