3 #ifndef DUNE_GEOGRID_ITERATOR_HH 4 #define DUNE_GEOGRID_ITERATOR_HH 11 #include <dune/geometry/referenceelements.hh> 28 bool fake = !Capabilities::hasHostEntity< Grid, codim >::v >
31 template<
class Gr
id >
39 template<
int codim, PartitionIteratorType pitype,
class Gr
id >
42 template<
int codim,
class Gr
id >
45 static const int dimension = std::remove_const< Grid >::type::dimension;
46 static const int codimension = codim;
50 typedef typename std::remove_const< Grid >::type::ctype
ctype;
51 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
54 static bool apply (
const RefElement &refElement,
55 const Element &element,
int subEntity )
57 const int size = refElement.size( subEntity, codim, dimension );
58 for(
int i = 0; i < size; ++i )
60 const int j = refElement.subEntity( subEntity, codim, i, dimension );
61 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
69 template<
int codim,
class Gr
id >
72 static const int dimension = std::remove_const< Grid >::type::dimension;
73 static const int codimension = codim;
77 typedef typename std::remove_const< Grid >::type::ctype
ctype;
78 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
81 static bool apply (
const RefElement &refElement,
82 const Element &element,
int subEntity )
88 template<
int codim,
class Gr
id >
91 static const int dimension = std::remove_const< Grid >::type::dimension;
92 static const int codimension = codim;
96 typedef typename std::remove_const< Grid >::type::ctype
ctype;
97 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
100 static bool apply (
const RefElement &refElement,
101 const Element &element,
int subEntity )
106 const int size = refElement.size( subEntity, codim, dimension );
107 for(
int i = 0; i < size; ++i )
109 const int j = refElement.subEntity( subEntity, codim, i, dimension );
110 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
118 template<
int codim,
class Gr
id >
121 static const int dimension = std::remove_const< Grid >::type::dimension;
122 static const int codimension = codim;
126 typedef typename std::remove_const< Grid >::type::ctype
ctype;
127 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
130 static bool apply (
const RefElement &refElement,
131 const Element &element,
int subEntity )
137 template<
int codim,
class Gr
id >
140 static const int dimension = std::remove_const< Grid >::type::dimension;
141 static const int codimension = codim;
145 typedef typename std::remove_const< Grid >::type::ctype
ctype;
146 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
149 static bool apply (
const RefElement &refElement,
150 const Element &element,
int subEntity )
156 template<
int codim,
class Gr
id >
159 static const int dimension = std::remove_const< Grid >::type::dimension;
160 static const int codimension = codim;
164 typedef typename std::remove_const< Grid >::type::ctype
ctype;
165 typedef typename std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity
Element;
168 static bool apply (
const RefElement &refElement,
169 const Element &element,
int subEntity )
171 const int size = refElement.size( subEntity, codim, dimension );
172 for(
int i = 0; i < size; ++i )
174 const int j = refElement.subEntity( subEntity, codim, i, dimension );
175 PartitionType type = element.template subEntity< dimension >( j ).partitionType();
188 template<
class HostGr
idView,
int codim, PartitionIteratorType pitype,
class G >
189 class Iterator< HostGridView, codim, pitype, G, false >
191 typedef typename std::remove_const< G >::type::Traits Traits;
194 typedef typename Traits::Grid
Grid;
196 static const int codimension = codim;
198 typedef typename Traits::template Codim< codimension >::Entity
Entity;
200 static const bool fake =
false;
205 typedef typename HostGridView::template Codim< codim >::template Partition< pitype >::Iterator HostEntityIterator;
210 Iterator (
const Grid &grid, HostEntityIterator hostEntityIterator )
212 hostEntityIterator_(
std::move( hostEntityIterator ) )
217 ++hostEntityIterator_;
222 return hostEntityIterator_ == rhs.hostEntityIterator_;
227 return EntityImpl( grid(), *hostEntityIterator_ );
230 int level ()
const {
return hostEntityIterator_.level(); }
238 static Iterator begin (
const Grid &grid,
const HostGridView &hostGridView )
240 HostEntityIterator hostEntityIterator = hostGridView.template begin< codimension, pitype >();
241 return Iterator( grid, std::move( hostEntityIterator ) );
244 static Iterator end (
const Grid &grid,
const HostGridView &hostGridView )
246 HostEntityIterator hostEntityIterator = hostGridView.template end< codimension, pitype >();
247 return Iterator( grid, std::move( hostEntityIterator ) );
257 return dereference() == rhs.dereference();
262 HostEntityIterator hostEntityIterator_;
270 template<
class HostGr
idView,
int codim, PartitionIteratorType pitype,
class G >
271 class Iterator< HostGridView, codim, pitype, G, true >
273 typedef typename std::remove_const< G >::type::Traits Traits;
276 typedef typename Traits::Grid
Grid;
278 static const int codimension = codim;
280 typedef typename Traits::template Codim< codimension >::Entity
Entity;
287 typedef typename HostGridView::template Codim<0>::template Partition< Filter::Element_Partition >::Iterator HostElementIterator;
288 typedef typename HostElementIterator::Entity HostElement;
289 typedef typename HostGridView::IndexSet HostIndexSet;
292 Iterator () : grid_( nullptr ), subEntity_( -1 ), hostIndexSet_( nullptr ) {}
294 Iterator (
const Grid &grid, HostElementIterator hostElementIterator, HostElementIterator hostEnd,
const HostIndexSet &hostIndexSet )
296 hostElementIterator_( hostElementIterator ),
299 hostIndexSet_( &hostIndexSet )
301 if( hostElementIterator_ != hostEnd_ )
303 visited_.resize( hostIndexSet_->size( codimension ), false );
310 typedef typename Traits::ctype ctype;
312 while( hostElementIterator_ != hostEnd_ )
314 const HostElement &hostElement = *hostElementIterator_;
316 const ReferenceElement< ctype, Traits::dimension > &refElement
317 = ReferenceElements< ctype, Traits::dimension >::general( hostElement.type() );
320 const int count = refElement.size( codimension );
321 for( ; subEntity_ < count; ++subEntity_ )
323 if( !Filter::apply( refElement, hostElement, subEntity_ ) )
326 const size_t index = hostIndexSet_->subIndex( hostElement, subEntity_, codimension );
327 if( !visited_[ index ] )
329 visited_[ index ] =
true;
333 ++hostElementIterator_;
340 return hostElementIterator_ == rhs.hostElementIterator_ && ( hostElementIterator_ == hostEnd_ || subEntity_ == rhs.subEntity_ );
345 return EntityImpl( grid(), *hostElementIterator_, subEntity_ );
348 int level ()
const {
return hostElementIterator_.level(); }
356 static Iterator begin (
const Grid &grid,
const HostGridView &hostGridView )
358 HostElementIterator first = hostGridView.template begin< 0, Filter::Element_Partition >();
359 HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
360 return Iterator( grid, std::move( first ), std::move( last ), hostGridView.indexSet() );
363 static Iterator end (
const Grid &grid,
const HostGridView &hostGridView )
365 HostElementIterator last = hostGridView.template end< 0, Filter::Element_Partition >();
366 return Iterator( grid, last, last, hostGridView.indexSet() );
376 return dereference() == rhs.dereference();
381 HostElementIterator hostElementIterator_, hostEnd_;
383 const HostIndexSet *hostIndexSet_;
384 std::vector< bool > visited_;
395 typedef typename std::remove_const< G >::type::Traits Traits;
398 typedef typename Traits::Grid
Grid;
400 static const int codimension = 0;
402 typedef typename Traits::template Codim< codimension >::Entity
Entity;
407 typedef typename Grid::HostGrid::HierarchicIterator HostEntityIterator;
414 hostEntityIterator_(
std::move( hostEntityIterator ) )
419 ++hostEntityIterator_;
424 return hostEntityIterator_ == rhs.hostEntityIterator_;
429 return EntityImpl( grid(), *hostEntityIterator_ );
432 int level ()
const {
return hostEntityIterator_.level(); }
447 return dereference() == rhs.dereference();
452 HostEntityIterator hostEntityIterator_;
459 #endif // #ifndef DUNE_GEOGRID_ITERATOR_HH only interior entities
Definition: gridenums.hh:135
void increment()
Definition: iterator.hh:308
all entities lying in the overlap zone
Definition: gridenums.hh:31
Iterator()
Definition: iterator.hh:292
const Grid & grid() const
Definition: iterator.hh:350
void increment()
Definition: iterator.hh:215
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:165
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:126
bool equals(const Iterator &rhs) const
Definition: iterator.hh:338
Definition: common/entitypointer.hh:597
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:47
static Iterator begin(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:238
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:402
ghost entities
Definition: gridenums.hh:33
int level() const
Definition: iterator.hh:348
void increment()
Definition: iterator.hh:417
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:164
Wrapper and interface class for a static iterator (EntityPointer)
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:128
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:98
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:134
Iterator()
Definition: iterator.hh:208
on boundary between interior and overlap
Definition: gridenums.hh:30
Traits::Grid Grid
Definition: iterator.hh:276
Traits::Grid Grid
Definition: iterator.hh:398
HierarchicIterator(const Grid &grid, HostEntityIterator hostEntityIterator)
Definition: iterator.hh:412
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:130
bool equals(const HierarchicIterator &rhs) const
Definition: iterator.hh:422
HierarchicIterator()
Definition: iterator.hh:410
interior, border, overlap and front entities
Definition: gridenums.hh:138
interior and border entities
Definition: gridenums.hh:136
Entity dereference() const
Definition: iterator.hh:343
interior, border, and overlap entities
Definition: gridenums.hh:137
all entities
Definition: gridenums.hh:139
const Grid & grid() const
Definition: iterator.hh:434
Iterator(const Grid &grid, HostEntityIterator hostEntityIterator)
Definition: iterator.hh:210
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:79
Entity dereference() const
Definition: iterator.hh:225
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:52
int level() const
Definition: iterator.hh:432
bool equals(const Dune::DefaultEntityPointer< Entity > &rhs) const
Definition: iterator.hh:255
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:198
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:146
Entity dereference() const
Definition: iterator.hh:427
bool equals(const Iterator &rhs) const
Definition: iterator.hh:220
Include standard header files.
Definition: agrid.hh:59
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:78
Traits::Grid Grid
Definition: iterator.hh:194
bool equals(const Dune::DefaultEntityPointer< Entity > &rhs) const
Definition: iterator.hh:374
Definition: iterator.hh:40
static Iterator end(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:244
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:166
ReferenceElement< ctype, dimension > RefElement
Definition: iterator.hh:147
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:127
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:54
bool equals(const Dune::DefaultEntityPointer< Entity > &rhs) const
Definition: iterator.hh:445
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:145
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:100
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:97
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:168
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:50
Iterator(const Grid &grid, HostElementIterator hostElementIterator, HostElementIterator hostEnd, const HostIndexSet &hostIndexSet)
Definition: iterator.hh:294
Definition: iterator.hh:29
std::remove_const< Grid >::type::Traits::template Codim< 0 >::Entity Element
Definition: iterator.hh:51
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:149
static bool apply(const RefElement &refElement, const Element &element, int subEntity)
Definition: iterator.hh:81
Traits::template Codim< codimension >::Entity Entity
Definition: iterator.hh:280
only ghost entities
Definition: gridenums.hh:140
const Grid & grid() const
Definition: iterator.hh:232
all interior entities
Definition: gridenums.hh:29
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:96
static Iterator end(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:363
int level() const
Definition: iterator.hh:230
static Iterator begin(const Grid &grid, const HostGridView &hostGridView)
Definition: iterator.hh:356
Definition: geometrygrid/entity.hh:55
std::remove_const< Grid >::type::ctype ctype
Definition: iterator.hh:77