3 #ifndef DUNE_GEOGRID_ENTITYPOINTER_HH
4 #define DUNE_GEOGRID_ENTITYPOINTER_HH
21 template<
int,
int,
class >
24 template<
class,
class >
33 template<
int codim,
class Gr
id >
34 struct EntityPointerTraits;
36 template<
class Traits,
bool fake = Traits::fake >
44 template<
int codim,
class Gr
id >
45 struct EntityPointerTraits;
48 template<
int codim,
class Gr
id >
49 struct EntityPointerTraits< codim, const Grid >
50 :
public EntityPointerTraits< codim, Grid >
54 template<
int codim,
class HostGr
id,
class CoordFunction,
class Allocator >
60 static const bool fake = !Capabilities::hasHostEntity< Grid, codim >::v;
62 typedef typename HostGrid::ctype
ctype;
64 static const int dimension = HostGrid::dimension;
65 static const int codimension = codim;
70 typedef typename HostGrid::template Codim< codim >::Entity
HostEntity;
74 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
83 template<
class Traits >
88 typedef typename Traits::Grid Grid;
90 typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
94 static const int dimension = Traits::dimension;
95 static const int codimension = Traits::codimension;
97 typedef typename Traits::Entity
Entity;
99 static const bool fake = Traits::fake;
116 hostEntityIterator_( hostEntityIterator )
121 hostEntityIterator_( hostEntityIterator )
126 hostEntityIterator_( hostElement.template subEntity< codimension >( subEntity ) )
131 hostEntityIterator_( grid.hostGrid().entityPointer( grid.getRealImplementation(seed).hostEntitySeed() ) )
136 hostEntityIterator_( entity.hostEntity() )
140 : entity_( other.entityImpl() ),
141 hostEntityIterator_( other.hostEntityIterator_ )
146 : entity_( other.entityImpl() ),
147 hostEntityIterator_( other.hostEntityIterator_ )
160 entityImpl() = other.entityImpl();
161 hostEntityIterator_ = other.hostEntityIterator_;
168 return (hostIterator() == other.hostIterator());
174 entityImpl().initialize( *hostIterator() );
178 int level ()
const {
return hostIterator().level(); }
182 const Grid &
grid ()
const {
return entityImpl().grid(); }
187 return Grid::getRealImplementation( entity_ );
202 template<
class Traits >
207 typedef typename Traits::Grid Grid;
209 typedef EntityPointerTraits< Traits::codimension, const Grid > BaseTraits;
213 static const int dimension = Traits::dimension;
214 static const int codimension = Traits::codimension;
218 static const bool fake = Traits::fake;
235 hostElementIterator_( hostElementIterator )
240 hostElementIterator_( hostElementIterator )
245 hostElementIterator_( hostElement )
249 : entity_(
EntityImpl( grid, grid.getRealImplementation(seed).subEntity() ) ),
250 hostElementIterator_( grid.hostGrid().entityPointer( grid.getRealImplementation(seed).hostElementSeed() ) )
255 hostElementIterator_( entity.hostElement() )
259 : entity_( other.entityImpl() ),
260 hostElementIterator_( other.hostElementIterator_ )
265 : entity_( other.entityImpl() ),
266 hostElementIterator_( other.hostElementIterator_ )
279 entityImpl() = other.entityImpl();
280 hostElementIterator_ = other.hostElementIterator_;
287 const bool thisEnd = (subEntity() < 0);
288 const bool otherEnd = (other.subEntity() < 0);
289 if( thisEnd || otherEnd )
290 return thisEnd && otherEnd;
292 const int lvl = level();
293 if( lvl != other.
level() )
296 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
297 = grid().hostGrid().levelIndexSet( lvl );
299 const HostElement &thisElement = *hostElementIterator();
300 assert( indexSet.contains( thisElement ) );
301 const HostElement &otherElement = *(other.hostElementIterator());
302 assert( indexSet.contains( otherElement ) );
304 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
305 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
306 return (thisIndex == otherIndex);
312 entityImpl().initialize( *hostElementIterator() );
316 int level ()
const {
return hostElementIterator().level(); }
318 const Grid &
grid ()
const {
return entityImpl().grid(); }
319 int subEntity ()
const {
return entityImpl().subEntity(); }
324 return Grid::getRealImplementation( entity_ );
329 return hostElementIterator_;
343 #endif // #ifndef DUNE_GEOGRID_ENTITYPOINTER_HH