3#ifndef DUNE_FOAMGRID_INTERSECTIONITERATORS_HH
4#define DUNE_FOAMGRID_INTERSECTIONITERATORS_HH
26template<
class Gr
idImp>
30 enum {dimworld = GridImp::dimensionworld};
31 enum {dimgrid = GridImp::dimension};
33 typedef typename GridImp::ctype ctype;
35 typedef std::vector<typename std::vector<const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>*>::const_iterator> ElementVector;
36 typedef typename ElementVector::const_iterator ElementVectorIterator;
41 template<
typename,
typename,
typename>
42 friend class Dune::IntersectionIterator;
51 if(facet==center->corners())
58 pushBackLeafNeighbours_(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_], leafNeighbors_);
59 if(leafNeighbors_->size()==1)
67 while(intersection_.impl().facetIndex_ != center->corners())
69 leafNeighborIterator_ = leafNeighbors_->begin();
70 intersection_.impl().neighbor_=*leafNeighborIterator_;
71 while(leafNeighborIterator_!=leafNeighbors_->end() &&
72 intersection_.impl().center_==**leafNeighborIterator_)
74 ++leafNeighborIterator_;
75 if(leafNeighborIterator_ != leafNeighbors_->end())
76 intersection_.impl().neighbor_=*leafNeighborIterator_;
78 if(leafNeighborIterator_==leafNeighbors_->end())
80 if(leafNeighbors_->size()==1)
87 ++intersection_.impl().facetIndex_;
88 if(intersection_.impl().facetIndex_ != center->corners())
90 leafNeighbors_->clear();
91 pushBackLeafNeighbours_(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_], leafNeighbors_);
99 if(intersection_.impl().facetIndex_ == center->corners())
107 FoamGridLeafIntersectionIterator(
const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* center)
108 : intersection_(FoamGridLeafIntersection<GridImp>(center,center->corners()))
113 void pushBackLeafNeighbours_(
const FoamGridEntityImp<dimgrid-1, dimgrid, dimworld, ctype>* facet, std::shared_ptr<ElementVector> leafNeighbours)
116 for(
auto it = facet->elements_.begin(); it != facet->elements_.end(); ++it)
117 leafNeighbours->push_back(it);
121 for(
auto&& son : facet->sons_)
122 pushBackLeafNeighbours_(son, leafNeighbours);
128 typedef Dune::Intersection<const GridImp, typename Dune::FoamGridLeafIntersection<GridImp> >
Intersection;
132 return intersection_.impl().equals(other.intersection_.impl());
138 if(intersection_.impl().facetIndex_ == intersection_.impl().center_->corners())
141 DUNE_THROW(InvalidStateException,
"Cannot increment a one past the end iterator");
144 if(leafNeighbors_->size()==1)
147 ++intersection_.impl().facetIndex_;
148 if(intersection_.impl().facetIndex_ < intersection_.impl().center_->corners()){
150 leafNeighbors_->clear();
151 pushBackLeafNeighbours_(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_], leafNeighbors_);
152 leafNeighborIterator_ = leafNeighbors_->begin();
153 intersection_.impl().neighbor_=*leafNeighborIterator_;
164 ++leafNeighborIterator_;
165 if(leafNeighborIterator_ != leafNeighbors_->end())
166 intersection_.impl().neighbor_=*leafNeighborIterator_;
170 while(intersection_.impl().facetIndex_ != intersection_.impl().center_->corners())
172 if(leafNeighbors_->size()==1)
179 while(leafNeighborIterator_ != leafNeighbors_->end() &&
180 intersection_.impl().center_==**leafNeighborIterator_)
183 ++leafNeighborIterator_;
184 if(leafNeighborIterator_ != leafNeighbors_->end())
185 intersection_.impl().neighbor_=*leafNeighborIterator_;
187 if(leafNeighborIterator_==leafNeighbors_->end())
189 if(leafNeighbors_->size()==1)
198 ++intersection_.impl().facetIndex_;
199 if(intersection_.impl().facetIndex_ < intersection_.impl().center_->corners())
201 leafNeighbors_->clear();
202 pushBackLeafNeighbours_(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_], leafNeighbors_);
204 leafNeighborIterator_ = leafNeighbors_->begin();
205 intersection_.impl().neighbor_=*leafNeighborIterator_;
213 if(intersection_.impl().facetIndex_ == intersection_.impl().center_->corners())
223 return intersection_;
229 std::shared_ptr<ElementVector> leafNeighbors_;
230 ElementVectorIterator leafNeighborIterator_;
237template<
class Gr
idImp>
241 enum { dimgrid = GridImp::dimension };
242 enum { dimworld = GridImp::dimensionworld };
244 typedef typename GridImp::ctype ctype;
249 template<
typename,
typename,
typename>
250 friend class Dune::IntersectionIterator;
261 if(facet==center->corners())
268 if(center->facet_[intersection_.impl().facetIndex_]->elements_.size()==1)
271 intersection_.impl().neighbor_ =
272 intersection_.impl().neighborEnd_=
273 intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.end();
278 while(intersection_.impl().facetIndex_ != center->corners())
280 intersection_.impl().neighbor_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.begin();
281 intersection_.impl().neighborEnd_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.end();
282 while(intersection_.impl().neighbor_!=intersection_.impl().neighborEnd_ &&
283 (intersection_.impl().center_==*intersection_.impl().neighbor_
284 ||intersection_.impl().center_->level()!=(*intersection_.impl().neighbor_)->level()))
286 ++intersection_.impl().neighbor_;
288 if(intersection_.impl().neighbor_==intersection_.impl().neighborEnd_)
290 if(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.size()==1)
296 ++intersection_.impl().facetIndex_;
302 if(intersection_.impl().facetIndex_ == center->corners())
311 FoamGridLevelIntersectionIterator(
const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>* center)
312 : intersection_(FoamGridLevelIntersection<GridImp>(center,center->corners()))
318 typedef Dune::Intersection<const GridImp, typename Dune::FoamGridLevelIntersection<GridImp> >
Intersection;
322 return intersection_.impl().equals(other.intersection_.impl());
327 if(intersection_.impl().facetIndex_==
328 intersection_.impl().center_->corners())
331 DUNE_THROW(InvalidStateException,
"Cannot increment a one past the end iterator");
334 if(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.size()==1)
337 ++intersection_.impl().facetIndex_;
338 if(intersection_.impl().facetIndex_ < intersection_.impl().center_->corners()){
340 intersection_.impl().neighbor_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.begin();
341 intersection_.impl().neighborEnd_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.end();;
352 ++intersection_.impl().neighbor_;
356 while(intersection_.impl().facetIndex_ != intersection_.impl().center_->corners())
358 if(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.size()==1)
361 intersection_.impl().neighbor_=intersection_.impl().neighborEnd_;
365 while(intersection_.impl().neighbor_!=intersection_.impl().neighborEnd_ &&
366 (intersection_.impl().center_==*intersection_.impl().neighbor_
367 ||intersection_.impl().center_->level()!=(*intersection_.impl().neighbor_)->level()))
370 ++intersection_.impl().neighbor_;
372 if(intersection_.impl().neighbor_==
373 intersection_.impl().neighborEnd_)
375 if(intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.size()==1)
383 ++intersection_.impl().facetIndex_;
384 if(intersection_.impl().facetIndex_ < intersection_.impl().center_->corners())
387 intersection_.impl().neighbor_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.begin();
388 intersection_.impl().neighborEnd_=intersection_.impl().center_->facet_[intersection_.impl().facetIndex_]->elements_.end();
396 if(intersection_.impl().facetIndex_ == intersection_.impl().center_->corners())
407 return intersection_;
The FoamGridEntity class.
The FoamGridLeafIntersection and FoamGridLevelIntersection classes.
The null iterator factory for intersections.
The implementation of entities in a FoamGrid.
Definition: foamgridentity.hh:54
Definition: foamgridintersectioniterators.hh:239
bool equals(const FoamGridLevelIntersectionIterator< GridImp > &other) const
equality
Definition: foamgridintersectioniterators.hh:321
Dune::Intersection< const GridImp, typename Dune::FoamGridLevelIntersection< GridImp > > Intersection
Definition: foamgridintersectioniterators.hh:318
void increment()
prefix increment
Definition: foamgridintersectioniterators.hh:326
const Intersection & dereference() const
dereferencing
Definition: foamgridintersectioniterators.hh:405
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: foamgridintersectioniterators.hh:28
Dune::Intersection< const GridImp, typename Dune::FoamGridLeafIntersection< GridImp > > Intersection
Definition: foamgridintersectioniterators.hh:128
void increment()
prefix increment
Definition: foamgridintersectioniterators.hh:136
bool equals(const FoamGridLeafIntersectionIterator< GridImp > &other) const
equality
Definition: foamgridintersectioniterators.hh:131
const Intersection & dereference() const
dereferencing
Definition: foamgridintersectioniterators.hh:222
Definition: foamgridintersections.hh:252
Iterator over all element neighborsMesh entities of codimension 0 ("elements") allow to visit all nei...
Definition: foamgridintersections.hh:386
static std::vector< constFoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > * >::const_iterator null()
Definition: foamgridnulliteratorfactory.hh:18
The actual entity implementation.
Definition: foamgridvertex.hh:47