5#ifndef DUNE_GEOGRID_ITERATOR_HH
6#define DUNE_GEOGRID_ITERATOR_HH
13#include <dune/geometry/referenceelements.hh>
29 bool fake = !Capabilities::hasHostEntity< Grid, codim >::v >
32 template<
class Gr
id >
40 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
43 template<
int codim,
class Gr
id >
46 static const int dimension = std::remove_const< Grid >::type::dimension;
47 static const int codimension = codim;
51 typedef typename std::remove_const< Grid >::type::ctype
ctype;
52 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
53 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
56 const Element &element,
int subEntity )
58 const int size = refElement.size( subEntity, codim, dimension );
59 for(
int i = 0; i < size; ++i )
61 const int j = refElement.subEntity( subEntity, codim, i, dimension );
62 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
70 template<
int codim,
class Gr
id >
73 static const int dimension = std::remove_const< Grid >::type::dimension;
74 static const int codimension = codim;
78 typedef typename std::remove_const< Grid >::type::ctype
ctype;
79 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
80 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
83 const Element &element,
int subEntity )
89 template<
int codim,
class Gr
id >
92 static const int dimension = std::remove_const< Grid >::type::dimension;
93 static const int codimension = codim;
97 typedef typename std::remove_const< Grid >::type::ctype
ctype;
98 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
99 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
102 const Element &element,
int subEntity )
107 const int size = refElement.size( subEntity, codim, dimension );
108 for(
int i = 0; i < size; ++i )
110 const int j = refElement.subEntity( subEntity, codim, i, dimension );
111 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
119 template<
int codim,
class Gr
id >
122 static const int dimension = std::remove_const< Grid >::type::dimension;
123 static const int codimension = codim;
127 typedef typename std::remove_const< Grid >::type::ctype
ctype;
128 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
129 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
132 const Element &element,
int subEntity )
138 template<
int codim,
class Gr
id >
141 static const int dimension = std::remove_const< Grid >::type::dimension;
142 static const int codimension = codim;
146 typedef typename std::remove_const< Grid >::type::ctype
ctype;
147 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
148 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
151 const Element &element,
int subEntity )
157 template<
int codim,
class Gr
id >
160 static const int dimension = std::remove_const< Grid >::type::dimension;
161 static const int codimension = codim;
165 typedef typename std::remove_const< Grid >::type::ctype
ctype;
166 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
167 typedef Transitional::ReferenceElement< ctype, Dim<dimension> >
RefElement;
170 const Element &element,
int subEntity )
172 const int size = refElement.size( subEntity, codim, dimension );
173 for(
int i = 0; i < size; ++i )
175 const int j = refElement.subEntity( subEntity, codim, i, dimension );
176 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
189 template<
class HostGr
idView,
int codim, PartitionIteratorType pitype,
class G >
190 class Iterator< HostGridView, codim, pitype, G, false >
192 typedef typename std::remove_const< G >::type::Traits Traits;
195 typedef typename Traits::Grid
Grid;
197 static const int codimension = codim;
199 typedef typename Traits::template Codim< codimension >::Entity
Entity;
201 static const bool fake =
false;
206 typedef typename HostGridView::template Codim< codim >::template Partition< pitype >::Iterator HostEntityIterator;
213 hostEntityIterator_(
std::move( hostEntityIterator ) )
218 ++hostEntityIterator_;
223 return hostEntityIterator_ == rhs.hostEntityIterator_;
228 return EntityImpl( grid(), *hostEntityIterator_ );
231 int level ()
const {
return hostEntityIterator_.level(); }
241 HostEntityIterator hostEntityIterator = hostGridView.template begin< codimension, pitype >();
242 return Iterator( grid, std::move( hostEntityIterator ) );
247 HostEntityIterator hostEntityIterator = hostGridView.template end< codimension, pitype >();
248 return Iterator( grid, std::move( hostEntityIterator ) );
253 HostEntityIterator hostEntityIterator_;
261 template<
class HostGr
idView,
int codim, PartitionIteratorType pitype,
class G >
262 class Iterator< HostGridView, codim, pitype, G, true >
264 typedef typename std::remove_const< G >::type::Traits Traits;
267 typedef typename Traits::Grid
Grid;
269 static const int codimension = codim;
271 typedef typename Traits::template Codim< codimension >::Entity
Entity;
278 typedef typename HostGridView::template Codim<0>::template Partition< Filter::Element_Partition >::Iterator HostElementIterator;
279 typedef typename HostElementIterator::Entity HostElement;
280 typedef typename HostGridView::IndexSet HostIndexSet;
283 Iterator () : grid_( nullptr ), subEntity_( -1 ), hostIndexSet_( nullptr ) {}
285 Iterator (
const Grid &grid, HostElementIterator hostElementIterator, HostElementIterator hostEnd,
const HostIndexSet &hostIndexSet )
287 hostElementIterator_( hostElementIterator ),
290 hostIndexSet_( &hostIndexSet )
292 if( hostElementIterator_ != hostEnd_ )
294 visited_.resize( hostIndexSet_->size( codimension ),
false );
301 typedef typename Traits::ctype ctype;
303 while( hostElementIterator_ != hostEnd_ )
305 const HostElement &hostElement = *hostElementIterator_;
307 auto refElement = referenceElement< ctype, Traits::dimension >( hostElement.type() );
310 const int count = refElement.size( codimension );
311 for( ; subEntity_ < count; ++subEntity_ )
313 if( !Filter::apply( refElement, hostElement, subEntity_ ) )
316 const size_t index = hostIndexSet_->subIndex( hostElement, subEntity_, codimension );
317 if( !visited_[ index ] )
319 visited_[ index ] =
true;
323 ++hostElementIterator_;
330 return hostElementIterator_ == rhs.hostElementIterator_ && ( hostElementIterator_ == hostEnd_ || subEntity_ == rhs.subEntity_ );
335 return EntityImpl( grid(), *hostElementIterator_, subEntity_ );
338 int level ()
const {
return hostElementIterator_.level(); }
348 HostElementIterator first = hostGridView.template begin< 0, Filter::Element_Partition >();
349 HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
350 return Iterator( grid, std::move( first ), std::move( last ), hostGridView.indexSet() );
355 HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
356 return Iterator( grid, last, last, hostGridView.indexSet() );
361 HostElementIterator hostElementIterator_, hostEnd_;
363 const HostIndexSet *hostIndexSet_;
364 std::vector< bool > visited_;
375 typedef typename std::remove_const< G >::type::Traits Traits;
378 typedef typename Traits::Grid
Grid;
382 typedef typename Traits::template Codim< codimension >::Entity
Entity;
387 typedef typename Grid::HostGrid::HierarchicIterator HostEntityIterator;
394 hostEntityIterator_(
std::move( hostEntityIterator ) )
399 ++hostEntityIterator_;
404 return hostEntityIterator_ == rhs.hostEntityIterator_;
412 int level ()
const {
return hostEntityIterator_.level(); }
422 HostEntityIterator hostEntityIterator_;
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
@ All_Partition
all entities
Definition: gridenums.hh:141
@ OverlapFront_Partition
interior, border, overlap and front entities
Definition: gridenums.hh:140
@ Interior_Partition
only interior entities
Definition: gridenums.hh:137
@ InteriorBorder_Partition
interior and border entities
Definition: gridenums.hh:138
@ Overlap_Partition
interior, border, and overlap entities
Definition: gridenums.hh:139
@ Ghost_Partition
only ghost entities
Definition: gridenums.hh:142
@ InteriorEntity
all interior entities
Definition: gridenums.hh:31
@ GhostEntity
ghost entities
Definition: gridenums.hh:35
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:32
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:33
Include standard header files.
Definition: agrid.hh:60
Grid abstract base class.
Definition: common/grid.hh:375
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:694
Definition: iterator.hh:374
static const int codimension
Definition: iterator.hh:380
int level() const
Definition: iterator.hh:412
void increment()
Definition: iterator.hh:397
bool equals(const HierarchicIterator &rhs) const
Definition: iterator.hh:402
Entity dereference() const
Definition: iterator.hh:407
HierarchicIterator()
Definition: iterator.hh:390
HierarchicIterator(const Grid &grid, HostEntityIterator hostEntityIterator)
Definition: iterator.hh:392
Traits::Grid Grid
Definition: iterator.hh:378
const Grid & grid() const
Definition: iterator.hh:414
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:382
Definition: iterator.hh:30
Definition: iterator.hh:41
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:51
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:52
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:55
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:53
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:80
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:82
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:78
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:79
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:99
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:98
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:101
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:97
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:128
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:127
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:129
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:131
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:150
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:146
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:148
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:147
Transitional::ReferenceElement< ctype, Dim< dimension > > RefElement
Definition: iterator.hh:167
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:166
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:165
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:169
Iterator()
Definition: iterator.hh:209
Traits::Grid Grid
Definition: iterator.hh:195
Entity dereference() const
Definition: iterator.hh:226
int level() const
Definition: iterator.hh:231
void increment()
Definition: iterator.hh:216
bool equals(const Iterator &rhs) const
Definition: iterator.hh:221
static Iterator begin(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:239
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:199
const Grid & grid() const
Definition: iterator.hh:233
static Iterator end(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:245
Iterator(const Grid &grid, HostEntityIterator hostEntityIterator)
Definition: iterator.hh:211
Traits::Grid Grid
Definition: iterator.hh:267
int level() const
Definition: iterator.hh:338
void increment()
Definition: iterator.hh:299
const Grid & grid() const
Definition: iterator.hh:340
static Iterator end(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:353
static Iterator begin(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:346
bool equals(const Iterator &rhs) const
Definition: iterator.hh:328
Entity dereference() const
Definition: iterator.hh:333
Iterator(const Grid &grid, HostElementIterator hostElementIterator, HostElementIterator hostEnd, const HostIndexSet &hostIndexSet)
Definition: iterator.hh:285
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:271
Iterator()
Definition: iterator.hh:283