3#ifndef DUNE_GEOGRID_ITERATOR_HH
4#define DUNE_GEOGRID_ITERATOR_HH
6#include <dune/geometry/referenceelements.hh>
8#include <dune/grid/geometrygrid/declaration.hh>
9#include <dune/grid/geometrygrid/entitypointer.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;
44 typedef ReferenceElement< ctype, dimension > RefElement;
46 static bool apply (
const RefElement &refElement,
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;
71 typedef ReferenceElement< ctype, dimension > RefElement;
73 static bool apply (
const RefElement &refElement,
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;
90 typedef ReferenceElement< ctype, dimension > RefElement;
92 static bool apply (
const RefElement &refElement,
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;
120 typedef ReferenceElement< ctype, dimension > RefElement;
122 static bool apply (
const RefElement &refElement,
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;
139 typedef ReferenceElement< ctype, dimension > RefElement;
141 static bool apply (
const RefElement &refElement,
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;
158 typedef ReferenceElement< ctype, dimension > RefElement;
160 static bool apply (
const RefElement &refElement,
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 >
181 struct IteratorTraits
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
198 typedef typename HostGridView::IndexSet HostIndexSet;
200 enum IteratorType { begin, end };
208 template<
class Traits >
209 class Iterator< Traits, false >
210 :
public EntityPointer< Traits, false >
212 typedef EntityPointer< Traits, false > Base;
214 typedef typename Traits::Grid Grid;
217 typedef typename Traits::IteratorType IteratorType;
219 using Base::codimension;
222 typedef typename Base::EntityImpl EntityImpl;
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_;
238 entityImpl() = EntityImpl( grid() );
247 template<
class Traits >
248 class Iterator< Traits, true >
249 :
public EntityPointer< Traits, true >
251 typedef EntityPointer< Traits, true > Base;
253 typedef typename Traits::Grid Grid;
256 static const int dimension = Traits::dimension;
257 static const int codimension = Traits::codimension;
259 typedef typename Traits::IteratorType IteratorType;
262 typedef typename Traits::Filter Filter;
264 typedef typename Traits::HostElement HostElement;
265 typedef typename Traits::HostElementIterator HostElementIterator;
266 typedef typename Traits::HostIndexSet HostIndexSet;
269 typedef typename Base::EntityImpl EntityImpl;
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
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 >
335 struct HierarchicIteratorTraits
336 :
public EntityPointerTraits< 0, Grid >
338 typedef typename remove_const< Grid >::type::Traits Traits;
340 typedef typename Traits::HostGrid::Traits::HierarchicIterator HostEntityIterator;
341 typedef typename Traits::HostGrid::Traits::HierarchicIterator HostElementIterator;
349 template<
class Gr
id >
350 class HierarchicIterator
351 :
public EntityPointer< HierarchicIteratorTraits< Grid > >
353 typedef HierarchicIteratorTraits< Grid > Traits;
355 typedef EntityPointer< Traits > Base;
358 typedef typename Base::EntityImpl EntityImpl;
359 typedef typename Traits::HostEntityIterator HostEntityIterator;
361 using Base::hostEntityIterator_;
362 using Base::entityImpl;
366 HierarchicIterator (
const Grid &grid,
367 const HostEntityIterator &hostEntityIterator )
368 : Base( grid, hostEntityIterator )
373 ++hostEntityIterator_;
374 entityImpl() = EntityImpl( grid() );
Dune namespace.
Definition: alignment.hh:14
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:130
@ All_Partition
all entities
Definition: gridenums.hh:135
@ OverlapFront_Partition
interior, border, overlap and front entities
Definition: gridenums.hh:134
@ Interior_Partition
only interior entities
Definition: gridenums.hh:131
@ InteriorBorder_Partition
interior and border entities
Definition: gridenums.hh:132
@ Overlap_Partition
interior, border, and overlap entities
Definition: gridenums.hh:133
@ Ghost_Partition
only ghost entities
Definition: gridenums.hh:136
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
@ InteriorEntity
all interior entities
Definition: gridenums.hh:25
@ GhostEntity
ghost entities
Definition: gridenums.hh:29
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:26
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:27
static const ReferenceElement< ctype, dim > & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:568