1#ifndef DUNE_SPGRID_BOUNDARYSEGMENTITERATOR_HH
2#define DUNE_SPGRID_BOUNDARYSEGMENTITERATOR_HH
13#include <dune/grid/common/intersection.hh>
14#include <dune/grid/common/intersectioniterator.hh>
17#include <dune/grid/spgrid/intersection.hh>
18#include <dune/grid/spgrid/iterator.hh>
27 template<
class Gr
id >
28 class SPBoundarySegmentIterator
31 typedef SPBoundarySegmentIterator< Grid > This;
33 typedef typename std::remove_const< Grid >::type::Traits Traits;
36 typedef SPIntersection< Grid > IntersectionImpl;
38 typedef SPPartitionIterator< 1, Grid > PartitionIterator;
48 static const int dimension = IntersectionImpl::dimension;
50 typedef typename IntersectionImpl::ctype ctype;
52 typedef typename IntersectionImpl::EntityInfo EntityInfo;
54 typedef typename IntersectionImpl::GridLevel GridLevel;
56 typedef typename GridLevel::PartitionList PartitionList;
58 typedef typename PartitionIterator::Begin Begin;
59 typedef typename PartitionIterator::End End;
63 static const int numFaces = GridLevel::ReferenceCube::numFaces;
66 typedef typename PartitionList::Partition Partition;
68 typedef typename PartitionList::MultiIndex MultiIndex;
72 SPBoundarySegmentIterator (
const GridLevel &gridLevel,
int face, Begin );
73 SPBoundarySegmentIterator (
const GridLevel &gridLevel,
int face, End );
76 SPBoundarySegmentIterator (
const This &other );
78 const This &operator= (
const This &other );
81 bool equals (
const This &other )
const;
87 const Intersection &dereference ()
const;
91 const GridLevel &gridLevel ()
const;
93 void init (
int face );
97 IntersectionImpl &intersectionImpl () {
return intersection_.impl(); }
99 const IntersectionImpl &intersectionImpl ()
const {
return intersection_.impl(); }
101 Intersection intersection_;
102 PartitionIterator pit_;
110 template<
class Gr
id >
111 inline SPBoundarySegmentIterator< Grid >
112 ::SPBoundarySegmentIterator (
const GridLevel &gridLevel,
int face, Begin )
113 : intersection_( IntersectionImpl( EntityInfo( gridLevel ), face ) ),
114 pit_( gridLevel, gridLevel.boundaryPartition( face ), Begin() )
120 template<
class Gr
id >
121 inline SPBoundarySegmentIterator< Grid >
122 ::SPBoundarySegmentIterator (
const GridLevel &gridLevel,
int face, End )
123 : intersection_( IntersectionImpl( EntityInfo( gridLevel ), face+1 ) ),
124 pit_( gridLevel, gridLevel.boundaryPartition( face+1 ), Begin() )
128 template<
class Gr
id >
129 inline SPBoundarySegmentIterator< Grid >::SPBoundarySegmentIterator (
const This &other )
130 : intersection_( other.intersectionImpl() ),
135 template<
class Gr
id >
136 inline const typename SPBoundarySegmentIterator< Grid >::This &
137 SPBoundarySegmentIterator< Grid >::operator= (
const This &other )
139 intersectionImpl() = other.intersectionImpl();
145 template<
class Gr
id >
146 inline const typename SPBoundarySegmentIterator< Grid >::Intersection &
147 SPBoundarySegmentIterator< Grid >::dereference ()
const
149 return intersection_;
153 template<
class Gr
id >
156 return (pit_ == other.pit_);
160 template<
class Gr
id >
161 inline void SPBoundarySegmentIterator< Grid >::increment ()
164 int face = This::face();
168 while( !pit_ && (face < numFaces) )
169 pit_ = PartitionIterator( gridLevel(), gridLevel().boundaryPartition( ++face ), Begin() );
175 template<
class Gr
id >
176 inline int SPBoundarySegmentIterator< Grid >::face ()
const
178 return intersection_.indexInInside();
182 template<
class Gr
id >
183 inline const typename SPBoundarySegmentIterator< Grid >::GridLevel &
184 SPBoundarySegmentIterator< Grid >::gridLevel ()
const
186 return intersectionImpl().gridLevel();
190 template<
class Gr
id >
191 inline void SPBoundarySegmentIterator< Grid >::init (
int face )
197 const SPEntity< 1, dimension, Grid > &entityImpl = ( *pit_ ).impl();
198 MultiIndex
id = entityImpl.entityInfo().id();
199 const int i = face >> 1;
200 const int j = 2*(face & 1) - 1;
204 const unsigned int number = entityImpl.entityInfo().partitionNumber();
205 EntityInfo entityInfo = EntityInfo( gridLevel(),
id, number );
206 intersectionImpl() = IntersectionImpl( entityInfo, face );
GridImp::template Codim< 0 >::Entity Entity
Type of entity that this Intersection belongs to.
Definition: intersection.hh:192
A few common exception classes.
Traits for type conversions and type information.
constexpr auto equals(T1 &&t1, T2 &&t2)
Equality comparison.
Definition: hybridutilities.hh:402
Dune namespace.
Definition: alignedallocator.hh:13