1 #ifndef DUNE_GEOGRID_ITERATOR_HH
2 #define DUNE_GEOGRID_ITERATOR_HH
4 #include <dune/geometry/referenceelements.hh>
18 template<
class Traits,
bool fake = Traits::fake >
21 template<
class Gr
id >
29 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
32 template<
int codim,
class Gr
id >
35 static const int dimension = remove_const< Grid >::type::dimension;
36 static const int codimension = codim;
40 typedef typename remove_const< Grid >::type::ctype
ctype;
41 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
45 const Element &element,
int subEntity )
47 const int size = refElement.size( subEntity, codim, dimension );
48 for(
int i = 0; i < size; ++i )
50 const int j = refElement.subEntity( subEntity, codim, i, dimension );
51 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
59 template<
int codim,
class Gr
id >
62 static const int dimension = remove_const< Grid >::type::dimension;
63 static const int codimension = codim;
67 typedef typename remove_const< Grid >::type::ctype
ctype;
68 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
72 const Element &element,
int subEntity )
78 template<
int codim,
class Gr
id >
81 static const int dimension = remove_const< Grid >::type::dimension;
82 static const int codimension = codim;
86 typedef typename remove_const< Grid >::type::ctype
ctype;
87 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
91 const Element &element,
int subEntity )
96 const int size = refElement.size( subEntity, codim, dimension );
97 for(
int i = 0; i < size; ++i )
99 const int j = refElement.subEntity( subEntity, codim, i, dimension );
100 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
108 template<
int codim,
class Gr
id >
111 static const int dimension = remove_const< Grid >::type::dimension;
112 static const int codimension = codim;
116 typedef typename remove_const< Grid >::type::ctype
ctype;
117 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
121 const Element &element,
int subEntity )
127 template<
int codim,
class Gr
id >
130 static const int dimension = remove_const< Grid >::type::dimension;
131 static const int codimension = codim;
135 typedef typename remove_const< Grid >::type::ctype
ctype;
136 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
140 const Element &element,
int subEntity )
146 template<
int codim,
class Gr
id >
149 static const int dimension = remove_const< Grid >::type::dimension;
150 static const int codimension = codim;
154 typedef typename remove_const< Grid >::type::ctype
ctype;
155 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
159 const Element &element,
int subEntity )
161 const int size = refElement.size( subEntity, codim, dimension );
162 for(
int i = 0; i < size; ++i )
164 const int j = refElement.subEntity( subEntity, codim, i, dimension );
165 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
178 template<
class Traits >
184 typedef typename Traits::Grid Grid;
192 using Base::hostEntityIterator_;
193 using Base::entityImpl;
198 :
Base( grid, Traits::getHostEntityIterator( grid.hostGrid(), level, type ) )
203 ++hostEntityIterator_;
213 template<
class Traits >
219 typedef typename Traits::Grid Grid;
222 static const int dimension = Traits::dimension;
223 static const int codimension = Traits::codimension;
228 typedef typename Traits::Filter Filter;
232 typedef typename Traits::HostIndexSet HostIndexSet;
237 using Base::hostElementIterator_;
238 using Base::entityImpl;
243 :
Base( grid, Traits::getHostElementIterator( grid.hostGrid(), level, type ), -1 ),
244 hostEnd_( Traits::getHostElementIterator( grid.hostGrid(), level, Traits::end ) ),
245 hostIndexSet_( &Traits::getHostIndexSet( grid.hostGrid(), level ) )
247 if( hostElementIterator_ != hostEnd_ )
249 visited_.resize( hostIndexSet_->size( codimension ), false );
256 typedef typename Traits::ctype ctype;
258 int subEntity = this->subEntity();
259 while( hostElementIterator_ != hostEnd_ )
261 const HostElement &hostElement = *hostElementIterator_;
263 const GenericReferenceElement< ctype, dimension > &refElement
264 = GenericReferenceElements< ctype, dimension >::general( hostElement.type() );
267 const int count = refElement.size( codimension );
268 for( ; subEntity < count; ++subEntity )
270 if( !Filter::apply( refElement, hostElement, subEntity ) )
273 const size_t index = hostIndexSet_->subIndex( hostElement, subEntity, codimension );
274 if( !visited_[ index ] )
276 visited_[ index ] =
true;
277 entityImpl() =
EntityImpl( grid(), subEntity );
281 ++hostElementIterator_;
284 entityImpl() =
EntityImpl( grid(), subEntity );
288 HostElementIterator hostEnd_;
289 const HostIndexSet *hostIndexSet_;
290 std::vector< bool > visited_;
298 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
309 typedef typename HostGrid::template Codim< codim >
310 ::template Partition< Entity_Partition >::LeafIterator
312 typedef typename HostGrid::template Codim< 0 >
313 ::template Partition< Element_Partition >::LeafIterator
324 return hostGrid.template leafbegin< codim, Entity_Partition >();
326 return hostGrid.template leafend< codim, Entity_Partition >();
333 return hostGrid.template leafbegin< 0, Element_Partition >();
335 return hostGrid.template leafend< 0, Element_Partition >();
340 return hostGrid.leafIndexSet();
349 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
360 typedef typename HostGrid::template Codim< codim >
361 ::template Partition< Entity_Partition >::LevelIterator
363 typedef typename HostGrid::template Codim< 0 >
364 ::template Partition< Element_Partition >::LevelIterator
375 return hostGrid.template lbegin< codim, Entity_Partition >( level );
377 return hostGrid.template lend< codim, Entity_Partition >( level );
384 return hostGrid.template lbegin< 0, Element_Partition >( level );
386 return hostGrid.template lend< 0, Element_Partition >( level );
391 return hostGrid.levelIndexSet( level );
400 template<
class Gr
id >
404 typedef typename remove_const< Grid >::type::Traits
Traits;
415 template<
class Gr
id >
427 using Base::hostEntityIterator_;
428 using Base::entityImpl;
434 :
Base( grid, hostEntityIterator )
439 ++hostEntityIterator_;
448 #endif // #ifndef DUNE_GEOGRID_ITERATOR_HH