Loading [MathJax]/extensions/tex2jax.js

dune-mmesh (1.4)

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{
19
28 template<class GridImp>
30 {
31
32 enum {dim=GridImp::dimension};
33
34 enum {dimworld=GridImp::dimensionworld};
35
36 // The type used to store coordinates
37 typedef typename GridImp::ctype ctype;
38
39 typedef typename GridImp::template HostGridEntity<0> HostGridEntity;
40
41 public:
42 typedef Dune::Intersection<const GridImp, Dune::MMeshLeafIntersection<GridImp> > Intersection;
43
46
48 MMeshLeafIntersectionIterator(const GridImp* mMesh,
49 const HostGridEntity& hostEntity)
50 : mMesh_(mMesh)
51 , hostEntity_(hostEntity)
52 , i_( 0 )
53 {
54 while( proceed() )
55 increment();
56 }
57
59 MMeshLeafIntersectionIterator(const GridImp* mMesh,
60 const HostGridEntity& hostEntity,
61 bool endDummy)
62 : mMesh_(mMesh)
63 , hostEntity_(hostEntity)
64 , i_( dim + 1 )
65 {}
66
68 bool equals(const MMeshLeafIntersectionIterator& other) const {
69 return i_ == other.i_ && hostEntity_ == other.hostEntity_;
70 }
71
73 void increment() {
74 do {
75 ++i_;
76 } while( proceed() );
77 }
78
80 Intersection dereference() const {
81 // remark: the i-th intersection in CGAL corresponds to the (dim-i)-th edge in DUNE
82 return MMeshLeafIntersection<GridImp>(mMesh_, hostEntity_, dim-i_);
83 }
84
85 private:
87 bool proceed()
88 {
89 if (i_ == dim + 1)
90 return false;
91
92 // on ghosts return intersection only if adjacent entity is interior
93 if (hostEntity_->info().partition == 2)
94 {
95 const auto& neighborHostEntity = hostEntity_->neighbor(dim-i_);
96
97 if (mMesh_->getHostGrid().is_infinite(neighborHostEntity))
98 return true;
99
100 // skip ghost neighbors
101 if (neighborHostEntity->info().partition != 0)
102 return true;
103 }
104 return false;
105 }
106
107 const GridImp* mMesh_;
108 HostGridEntity hostEntity_;
109 int i_;
110 };
111
112} // namespace Dune
113
114#endif
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: intersectioniterator.hh:30
MMeshLeafIntersectionIterator(const GridImp *mMesh, const HostGridEntity &hostEntity)
constructor for (begin) iterator
Definition: intersectioniterator.hh:48
MMeshLeafIntersectionIterator(const GridImp *mMesh, const HostGridEntity &hostEntity, bool endDummy)
constructor for end iterator
Definition: intersectioniterator.hh:59
void increment()
prefix increment
Definition: intersectioniterator.hh:73
MMeshLeafIntersectionIterator()
default constructor
Definition: intersectioniterator.hh:45
Intersection dereference() const
dereferencing
Definition: intersectioniterator.hh:80
bool equals(const MMeshLeafIntersectionIterator &other) const
returns if iterators reference same intersection
Definition: intersectioniterator.hh:68
An intersection with a leaf neighbor elementMesh entities of codimension 0 ("elements") allow to visi...
Definition: intersections.hh:37
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 (Apr 13, 22:42, 2025)