1 #ifndef DUNE_GEOGRID_ENTITYPOINTER_HH
2 #define DUNE_GEOGRID_ENTITYPOINTER_HH
19 template<
int,
int,
class >
22 template<
class,
class >
31 template<
int codim,
class Gr
id >
32 struct EntityPointerTraits;
34 template<
class Traits,
bool fake = Traits::fake >
42 template<
int codim,
class Gr
id >
43 struct EntityPointerTraits;
46 template<
int codim,
class Gr
id >
47 struct EntityPointerTraits< codim, const Grid >
48 :
public EntityPointerTraits< codim, Grid >
52 template<
int codim,
class HostGr
id,
class CoordFunction,
class Allocator >
58 static const bool fake = !Capabilities::hasHostEntity< Grid, codim >::v;
60 typedef typename HostGrid::ctype
ctype;
62 static const int dimension = HostGrid::dimension;
63 static const int codimension = codim;
66 typedef GeoGrid::EntitySeed< codimension, const Grid >
EntitySeed;
68 typedef typename HostGrid::template Codim< codim >::Entity
HostEntity;
72 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
81 template<
class Traits >
86 typedef typename Traits::Grid Grid;
88 typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
92 static const int dimension = Traits::dimension;
93 static const int codimension = Traits::codimension;
95 typedef typename Traits::Entity
Entity;
97 static const bool fake = Traits::fake;
114 hostEntityIterator_( hostEntityIterator )
119 hostEntityIterator_( hostEntityIterator )
124 hostEntityIterator_( hostElement.template subEntity< codimension >( subEntity ) )
129 hostEntityIterator_( grid.hostGrid().entityPointer( seed.hostEntitySeed() ) )
134 hostEntityIterator_( entity.hostEntity() )
138 : entity_( other.entityImpl() ),
139 hostEntityIterator_( other.hostEntityIterator_ )
144 : entity_( other.entityImpl() ),
145 hostEntityIterator_( other.hostEntityIterator_ )
163 entityImpl() = other.entityImpl();
164 hostEntityIterator_ = other.hostEntityIterator_;
171 return (hostIterator() == other.hostIterator());
177 entityImpl().initialize( *hostIterator() );
181 int level ()
const {
return hostIterator().level(); }
185 const Grid &
grid ()
const {
return entityImpl().grid(); }
190 return Grid::getRealImplementation( entity_ );
205 template<
class Traits >
210 typedef typename Traits::Grid Grid;
212 typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
216 static const int dimension = Traits::dimension;
217 static const int codimension = Traits::codimension;
221 static const bool fake = Traits::fake;
238 hostElementIterator_( hostElementIterator )
243 hostElementIterator_( hostElementIterator )
248 hostElementIterator_( hostElement )
252 : entity_(
EntityImpl( grid, seed.subEntity() ) ),
253 hostElementIterator_( grid.hostGrid().entityPointer( seed.hostElementSeed() ) )
258 hostElementIterator_( entity.hostElement() )
262 : entity_( other.entityImpl() ),
263 hostElementIterator_( other.hostElementIterator_ )
268 : entity_( other.entityImpl() ),
269 hostElementIterator_( other.hostElementIterator_ )
287 entityImpl() = other.entityImpl();
288 hostElementIterator_ = other.hostElementIterator_;
295 const bool thisEnd = (subEntity() < 0);
296 const bool otherEnd = (other.subEntity() < 0);
297 if( thisEnd || otherEnd )
298 return thisEnd && otherEnd;
300 const int lvl = level();
301 if( lvl != other.
level() )
304 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
305 = grid().hostGrid().levelIndexSet( lvl );
307 const HostElement &thisElement = *hostElementIterator();
308 assert( indexSet.contains( thisElement ) );
309 const HostElement &otherElement = *(other.hostElementIterator());
310 assert( indexSet.contains( otherElement ) );
312 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
313 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
314 return (thisIndex == otherIndex);
320 entityImpl().initialize( *hostElementIterator() );
324 int level ()
const {
return hostElementIterator().level(); }
326 const Grid &
grid ()
const {
return entityImpl().grid(); }
327 int subEntity ()
const {
return entityImpl().subEntity(); }
332 return Grid::getRealImplementation( entity_ );
337 return hostElementIterator_;
351 #endif // #ifndef DUNE_GEOGRID_ENTITYPOINTER_HH