3 #ifndef DUNE_GEOGRID_ITERATOR_HH
4 #define DUNE_GEOGRID_ITERATOR_HH
6 #include <dune/geometry/referenceelements.hh>
20 template<
class Traits,
bool fake = Traits::fake >
23 template<
class Gr
id >
24 class HierarchicIterator;
31 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
32 struct PartitionIteratorFilter;
34 template<
int codim,
class Gr
id >
37 static const int dimension = remove_const< Grid >::type::dimension;
38 static const int codimension = codim;
42 typedef typename remove_const< Grid >::type::ctype
ctype;
43 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
47 const Element &element,
int subEntity )
49 const int size = refElement.size( subEntity, codim, dimension );
50 for(
int i = 0; i < size; ++i )
52 const int j = refElement.subEntity( subEntity, codim, i, dimension );
53 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
61 template<
int codim,
class Gr
id >
64 static const int dimension = remove_const< Grid >::type::dimension;
65 static const int codimension = codim;
69 typedef typename remove_const< Grid >::type::ctype
ctype;
70 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
74 const Element &element,
int subEntity )
80 template<
int codim,
class Gr
id >
83 static const int dimension = remove_const< Grid >::type::dimension;
84 static const int codimension = codim;
88 typedef typename remove_const< Grid >::type::ctype
ctype;
89 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
93 const Element &element,
int subEntity )
98 const int size = refElement.size( subEntity, codim, dimension );
99 for(
int i = 0; i < size; ++i )
101 const int j = refElement.subEntity( subEntity, codim, i, dimension );
102 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
110 template<
int codim,
class Gr
id >
113 static const int dimension = remove_const< Grid >::type::dimension;
114 static const int codimension = codim;
118 typedef typename remove_const< Grid >::type::ctype
ctype;
119 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
123 const Element &element,
int subEntity )
129 template<
int codim,
class Gr
id >
132 static const int dimension = remove_const< Grid >::type::dimension;
133 static const int codimension = codim;
137 typedef typename remove_const< Grid >::type::ctype
ctype;
138 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
142 const Element &element,
int subEntity )
148 template<
int codim,
class Gr
id >
151 static const int dimension = remove_const< Grid >::type::dimension;
152 static const int codimension = codim;
156 typedef typename remove_const< Grid >::type::ctype
ctype;
157 typedef typename remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
161 const Element &element,
int subEntity )
163 const int size = refElement.size( subEntity, codim, dimension );
164 for(
int i = 0; i < size; ++i )
166 const int j = refElement.subEntity( subEntity, codim, i, dimension );
167 PartitionType type = element.template subEntity< dimension >( j )->partitionType();
180 template<
class HostGr
idView,
int codim, PartitionIteratorType pitype,
class Gr
id >
182 :
public EntityPointerTraits< codim, Grid >
184 typedef typename EntityPointerTraits< codim, Grid >::HostGrid
HostGrid;
186 typedef PartitionIteratorFilter< codim, pitype, HostGrid >
Filter;
191 typedef typename HostGridView::template Codim< codim >
192 ::template Partition< Entity_Partition >::Iterator
194 typedef typename HostGridView::template Codim< 0 >
195 ::template Partition< Element_Partition >::Iterator
208 template<
class Traits >
209 class Iterator< Traits, false >
214 typedef typename Traits::Grid Grid;
219 using Base::codimension;
224 using Base::hostEntityIterator_;
225 using Base::entityImpl;
229 template<
class HostGr
idView >
230 Iterator (
const Grid &grid,
const HostGridView &hostGridView,
IteratorType type )
231 :
Base( grid, (type == Traits::begin ? hostGridView.template begin< codimension, Traits::Entity_Partition >()
232 : hostGridView.template end< codimension, Traits::Entity_Partition >()) )
237 ++hostEntityIterator_;
247 template<
class Traits >
248 class Iterator< Traits, true >
253 typedef typename Traits::Grid Grid;
256 static const int dimension = Traits::dimension;
257 static const int codimension = Traits::codimension;
262 typedef typename Traits::Filter Filter;
266 typedef typename Traits::HostIndexSet HostIndexSet;
271 using Base::hostElementIterator_;
272 using Base::entityImpl;
276 template<
class HostGr
idView >
277 Iterator (
const Grid &grid,
const HostGridView &hostGridView,
IteratorType type )
278 :
Base( grid, (type == Traits::begin ? hostGridView.template begin< 0, Traits::Element_Partition >()
279 : hostGridView.template end< 0, Traits::Element_Partition >()), -1 ),
280 hostEnd_( hostGridView.template end< 0, Traits::Element_Partition >() ),
281 hostIndexSet_( &hostGridView.indexSet() )
283 if( hostElementIterator_ != hostEnd_ )
285 visited_.resize( hostIndexSet_->size( codimension ), false );
292 typedef typename Traits::ctype ctype;
294 int subEntity = this->subEntity();
295 while( hostElementIterator_ != hostEnd_ )
297 const HostElement &hostElement = *hostElementIterator_;
299 const ReferenceElement< ctype, dimension > &refElement
300 = ReferenceElements< ctype, dimension >::general( hostElement.type() );
303 const int count = refElement.size( codimension );
304 for( ; subEntity < count; ++subEntity )
306 if( !Filter::apply( refElement, hostElement, subEntity ) )
309 const size_t index = hostIndexSet_->subIndex( hostElement, subEntity, codimension );
310 if( !visited_[ index ] )
312 visited_[ index ] =
true;
313 entityImpl() =
EntityImpl( grid(), subEntity );
317 ++hostElementIterator_;
320 entityImpl() =
EntityImpl( grid(), subEntity );
324 HostElementIterator hostEnd_;
325 const HostIndexSet *hostIndexSet_;
326 std::vector< bool > visited_;
334 template<
class Gr
id >
336 :
public EntityPointerTraits< 0, Grid >
338 typedef typename remove_const< Grid >::type::Traits
Traits;
349 template<
class Gr
id >
361 using Base::hostEntityIterator_;
362 using Base::entityImpl;
368 :
Base( grid, hostEntityIterator )
373 ++hostEntityIterator_;
382 #endif // #ifndef DUNE_GEOGRID_ITERATOR_HH