5#ifndef DUNE_GEOGRID_ENTITY_HH
6#define DUNE_GEOGRID_ENTITY_HH
8#include <dune/geometry/referenceelements.hh>
33 template<
int codim,
class Gr
id,
bool fake = !(Capabilities::hasHostEntity< Gr
id, codim >::v) >
48 template<
int codim,
int dim,
class Gr
id >
56 template<
class Gr
id >
59 template<
class Gr
id,
class HostIntersectionIterator >
74 template<
int codim,
class Gr
id >
77 typedef typename std::remove_const< Grid >::type::Traits Traits;
84 static const int codimension = codim;
86 static const int dimension = Traits::dimension;
88 static const int mydimension = dimension - codimension;
90 static const int dimensionworld = Traits::dimensionworld;
93 static const bool fake =
false;
101 typedef typename Traits::ctype
ctype;
104 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
108 typedef typename Traits::HostGrid HostGrid;
109 typedef typename Traits::CoordFunction CoordFunction;
116 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
119 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
122 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
125 typedef typename Traits::template Codim< codim >::GeometryImpl
GeometryImpl;
128 typedef typename HostGrid::template Codim< codimension >::Geometry HostGeometry;
143 : hostEntity_( grid.hostGrid().entity( seed.impl().hostEntitySeed() ) )
148 : hostEntity_( hostElement.template subEntity<codim>(i) )
154 : hostEntity_( hostEntity )
155 , grid_( &geo.grid() )
160 : hostEntity_(
std::move( hostEntity ) )
161 , grid_( &geo.grid() )
166 : hostEntity_( hostEntity )
171 : hostEntity_(
std::move( hostEntity ) )
177 : hostEntity_( other.hostEntity_ )
178 , grid_( other.grid_ )
183 : hostEntity_(
std::move( other.hostEntity_ ) )
184 , grid_( other.grid_ )
185 , geo_(
std::move( other.geo_ ) )
192 hostEntity_ = other.hostEntity_;
200 hostEntity_ = std::move( other.hostEntity_ );
201 grid_ = std::move( other.grid_ );
202 geo_ = std::move( other.geo_ );
209 return hostEntity_ == other.hostEntity_;
222 return hostEntity().type();
228 return hostEntity().level();
234 return hostEntity().partitionType();
255 CoordVector coords( hostEntity(), grid().coordFunction() );
263 return hostEntity().subEntities( cc );
274 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
295 template<
class HostIndexSet >
296 typename HostIndexSet::IndexType
297 index (
const HostIndexSet &indexSet )
const
299 return indexSet.template index< codimension >( hostEntity() );
311 template<
class HostIndexSet >
312 typename HostIndexSet::IndexType
313 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
315 return indexSet.subIndex( hostEntity(), i, cd );
325 template<
class HostIndexSet >
328 return indexSet.contains( hostEntity() );
338 template<
class HostIdSet >
339 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
341 return idSet.template id< codimension >( hostEntity() );
346 HostEntity hostEntity_;
348 mutable GeometryImpl geo_;
363 template<
int codim,
class Gr
id >
366 typedef typename std::remove_const< Grid >::type::Traits Traits;
373 static const int codimension = codim;
375 static const int dimension = Traits::dimension;
377 static const int mydimension = dimension - codimension;
379 static const int dimensionworld = Traits::dimensionworld;
382 static const bool fake =
true;
389 typedef typename Traits::ctype
ctype;
392 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
396 typedef typename Traits::HostGrid HostGrid;
397 typedef typename Traits::CoordFunction CoordFunction;
404 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
407 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
410 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
413 typedef typename Traits::template Codim< codimension >::GeometryImpl
GeometryImpl;
416 typedef typename HostGrid::template Codim< 0 >::Geometry HostGeometry;
432 : hostElement_(hostElement)
433 , subEntity_(subEntity)
438 : hostElement_( grid.hostGrid().entity( seed.impl().hostElementSeed() ) )
439 , subEntity_( seed.impl().subEntity() )
444 : hostElement_( other.hostElement_ )
445 , subEntity_( other.subEntity_ )
451 : hostElement_(
std::move( other.hostElement_ ) )
452 , subEntity_(
std::move( other.subEntity_ ) )
453 , grid_(
std::move( other.grid_ ) )
454 , geo_(
std::move( other.geo_ ) )
464 DUNE_THROW(Dune::Exception,
"GeometryGrid: Cannot create fake entity of codim " << codimension <<
" from real host entity.");
471 hostElement_ = other.hostElement_;
472 subEntity_ = other.subEntity_;
480 hostElement_ = std::move( other.hostElement_ );
481 subEntity_ = std::move( other.subEntity_ );
482 grid_ = std::move( other.grid_ );
483 geo_ = std::move( other.geo_ );
490 const bool thisEnd = (subEntity() < 0);
491 const bool otherEnd = (other.subEntity() < 0);
492 if( thisEnd || otherEnd )
493 return thisEnd && otherEnd;
495 const int lvl = level();
496 if( lvl != other.level() )
499 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
500 = grid().hostGrid().levelIndexSet( lvl );
503 assert( indexSet.contains( thisElement ) );
504 const HostElement &otherElement = other.hostElement();
505 assert( indexSet.contains( otherElement ) );
507 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
508 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
509 return (thisIndex == otherIndex);
521 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
522 return refElement.type( subEntity_, codimension );
528 return hostElement().level();
534 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
540 const int numVertices = refElement.size( subEntity_, codimension, dimension );
541 for(
int i = 1; i < numVertices; ++i )
543 PartitionType vtxType = vertexPartitionType( refElement, i );
546 if( type != vtxType )
571 CoordVector coords( hostElement(), subEntity_, grid().coordFunction() );
579 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
580 return refElement.size( subEntity_, codimension, cc );
590 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
594 DUNE_THROW( NotImplemented,
"HostGrid has no entities of codimension " << codimension <<
"." );
620 template<
class HostIndexSet >
621 typename HostIndexSet::IndexType
index (
const HostIndexSet &indexSet )
const
623 return indexSet.subIndex( hostElement(), subEntity_, codimension );
635 template<
class HostIndexSet >
636 typename HostIndexSet::IndexType
637 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
639 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
640 const int j = refElement.subEntity( subEntity_, codimension, i, codimension+cd );
641 return indexSet.subIndex( hostElement(), j, codimension+cd );
651 template<
class HostIndexSet >
654 return indexSet.contains( hostElement() );
664 template<
class HostIdSet >
665 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
667 return idSet.subId( hostElement(), subEntity_, codimension );
673 vertexPartitionType ( Dune::Transitional::ReferenceElement< ctype, Dim<dimension> > refElement,
int i )
const
675 const int j = refElement.subEntity( subEntity_, codimension, i, dimension );
676 return hostElement().template subEntity< dimension >( j ).partitionType();
680 HostElement hostElement_;
681 unsigned int subEntity_;
683 mutable GeometryImpl geo_;
691 template<
int codim,
int dim,
class Gr
id >
719 template<
int dim,
class Gr
id >
725 typedef typename std::remove_const< Grid >::type::Traits Traits;
727 typedef typename Traits::HostGrid HostGrid;
734 static const int codimension = Base::codimension;
736 static const int dimension = Base::dimension;
738 static const int mydimension = Base::mydimension;
740 static const int dimensionworld = Base::dimensionworld;
743 static const bool fake = Base::fake;
750 typedef typename Traits::template Codim< codimension >::LocalGeometry
LocalGeometry;
769 using Base::hostEntity;
785 template<
int codim >
786 typename Grid::template Codim< codim >::Entity
789 typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
790 return EntityImpl( grid(), hostEntity(), i );
796 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelbegin() );
802 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelend() );
808 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafbegin() );
814 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafend() );
819 return hostEntity().hasBoundaryIntersections();
824 return hostEntity().isLeaf();
829 return Entity( grid(), hostEntity().father() );
834 return hostEntity().hasFather();
839 return hostEntity().geometryInFather();
845 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
851 return HierarchicIteratorImpl( grid(), hostEntity().hend( maxLevel ) );
856 return hostEntity().isRegular();
861 return hostEntity().isNew();
866 return hostEntity().mightVanish();
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
@ FrontEntity
on boundary between overlap and ghost
Definition: gridenums.hh:34
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:32
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:33
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Wrapper class for entities.
Definition: common/entity.hh:66
EntitySeedImp Implementation
type of underlying implementation
Definition: common/entityseed.hh:37
Grid abstract base class.
Definition: common/grid.hh:375
Definition: cornerstorage.hh:22
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:694
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:705
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:707
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:708
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:698
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:699
Entity()
Definition: geometrygrid/entity.hh:703
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:700
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:701
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition: geometrygrid/entity.hh:710
Definition: iterator.hh:374
Definition: geometrygrid/intersectioniterator.hh:21
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:220
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition: geometrygrid/entity.hh:147
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:207
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:170
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:182
EntityBase()
Definition: geometrygrid/entity.hh:136
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:101
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:261
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:276
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:159
Geometry geometry() const
Definition: geometrygrid/entity.hh:251
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition: geometrygrid/entity.hh:286
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:267
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:339
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:125
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:153
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:104
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:116
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:119
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:176
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:165
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:297
const Grid & grid() const
Definition: geometrygrid/entity.hh:274
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:142
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:122
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:232
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:226
HostIndexSet::IndexType subIndex(const HostIndexSet &indexSet, int i, unsigned int cd) const
obtain the index of a subentity from a host IndexSet
Definition: geometrygrid/entity.hh:313
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:326
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:443
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:526
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:410
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:450
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:592
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:532
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:488
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:621
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:407
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:392
EntityBase(const Grid &grid, const HostElement &hostElement, unsigned int subEntity)
Definition: geometrygrid/entity.hh:431
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:665
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:577
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:584
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:437
HostIndexSet::IndexType subIndex(const HostIndexSet &indexSet, int i, unsigned int cd) const
obtain the index of a subentity from a host IndexSet
Definition: geometrygrid/entity.hh:637
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:413
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:462
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition: geometrygrid/entity.hh:611
const HostElement & hostElement() const
Definition: geometrygrid/entity.hh:597
Geometry geometry() const
Definition: geometrygrid/entity.hh:567
const Grid & grid() const
Definition: geometrygrid/entity.hh:590
EntityBase()
Definition: geometrygrid/entity.hh:424
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:389
int subEntity() const
Definition: geometrygrid/entity.hh:602
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:652
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:519
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:404
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition: geometrygrid/entity.hh:752
bool hasBoundaryIntersections() const
Definition: geometrygrid/entity.hh:817
LevelIntersectionIterator ilevelend() const
Definition: geometrygrid/entity.hh:799
Entity(const Grid &g, const HostEntity &hostE, int i)
Definition: geometrygrid/entity.hh:780
bool isLeaf() const
Definition: geometrygrid/entity.hh:822
bool isRegular() const
Definition: geometrygrid/entity.hh:854
HierarchicIterator hbegin(int maxLevel) const
Definition: geometrygrid/entity.hh:842
HierarchicIterator hend(int maxLevel) const
Definition: geometrygrid/entity.hh:848
Entity(const Grid &g, const HostEntity &hostE)
Definition: geometrygrid/entity.hh:773
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: geometrygrid/entity.hh:755
Entity(const GeometryImpl &geo, HostEntity &&hostE)
Definition: geometrygrid/entity.hh:776
bool hasFather() const
Definition: geometrygrid/entity.hh:832
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: geometrygrid/entity.hh:757
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygrid/entity.hh:787
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: geometrygrid/entity.hh:759
Entity()
Definition: geometrygrid/entity.hh:771
Entity(const GeometryImpl &geo, const HostEntity &hostE)
Definition: geometrygrid/entity.hh:775
Entity(const Grid &g, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:778
Entity(const Grid &g, HostEntity &&hostE)
Definition: geometrygrid/entity.hh:774
LeafIntersectionIterator ileafend() const
Definition: geometrygrid/entity.hh:811
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:763
LeafIntersectionIterator ileafbegin() const
Definition: geometrygrid/entity.hh:805
bool isNew() const
Definition: geometrygrid/entity.hh:859
LevelIntersectionIterator ilevelbegin() const
Definition: geometrygrid/entity.hh:793
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:766
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:764
bool mightVanish() const
Definition: geometrygrid/entity.hh:864
LocalGeometry geometryInFather() const
Definition: geometrygrid/entity.hh:837
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: geometrygrid/entity.hh:750
EntityFacade father() const
Definition: geometrygrid/entity.hh:827
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:765
Different resources needed by all grid implementations.