5 #ifndef DUNE_GEOGRID_ENTITY_HH 6 #define DUNE_GEOGRID_ENTITY_HH 8 #include <dune/geometry/referenceelements.hh> 33 template< int codim, class Grid, bool fake = !(Capabilities::hasHostEntity< Grid, 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;
83 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;
100 typedef typename Traits::ctype
ctype;
108 typedef typename Traits::HostGrid HostGrid;
109 typedef typename Traits::CoordFunction CoordFunction;
125 typedef typename Traits::template Codim< codim >::GeometryImpl
GeometryImpl;
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;
372 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;
388 typedef typename Traits::ctype
ctype;
396 typedef typename Traits::HostGrid HostGrid;
397 typedef typename Traits::CoordFunction CoordFunction;
413 typedef typename Traits::template Codim< codimension >::GeometryImpl
GeometryImpl;
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 );
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 >
693 :
public EntityBase< codim, Grid >
719 template<
int dim,
class Gr
id >
725 typedef typename std::remove_const< Grid >::type::Traits Traits;
727 typedef typename Traits::HostGrid HostGrid;
733 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;
749 typedef typename Traits::template Codim< codimension >::LocalGeometry
LocalGeometry;
769 using Base::hostEntity;
785 template<
int codim >
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();
874 #endif // #ifndef DUNE_GEOGRID_ENTITY_HH HierarchicIterator hend(int maxLevel) const
Definition: geometrygrid/entity.hh:848
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:170
Entity(const Grid &g, const HostEntity &hostE)
Definition: geometrygrid/entity.hh:773
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:584
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:519
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:176
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:30
const Grid & grid() const
Definition: geometrygrid/entity.hh:274
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:526
concept Entity
Model of a grid entity.
Definition: concepts/entity.hh:119
Entity(const Grid &g, const HostEntity &hostE, int i)
Definition: geometrygrid/entity.hh:780
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:142
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:104
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:700
on boundary between interior and overlap
Definition: gridenums.hh:32
const HostElement & hostElement() const
Definition: geometrygrid/entity.hh:597
on boundary between overlap and ghost
Definition: gridenums.hh:34
EntityFacade father() const
Definition: geometrygrid/entity.hh:827
bool hasBoundaryIntersections() const
Definition: geometrygrid/entity.hh:817
Geometry geometry() const
Definition: geometrygrid/entity.hh:567
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:701
const Grid & grid() const
Definition: geometrygrid/entity.hh:590
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:392
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:577
EntityBase()
Definition: geometrygrid/entity.hh:136
EntityBase()
Definition: geometrygrid/entity.hh:424
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:326
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:339
LocalGeometry geometryInFather() const
Definition: geometrygrid/entity.hh:837
Entity(const Grid &g, HostEntity &&hostE)
Definition: geometrygrid/entity.hh:774
Grid abstract base classThis class is the base class for all grid implementations. Although no virtual functions are used we call it abstract since its methods do not contain an implementation but forward to the methods of the derived class via the Barton-Nackman trick.
Definition: common/grid.hh:375
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:699
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:707
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
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:766
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:450
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:220
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:232
int subEntity() const
Definition: geometrygrid/entity.hh:602
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:410
concept Geometry
Model of a geometry object.
Definition: concepts/geometry.hh:29
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
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:665
bool isRegular() const
Definition: geometrygrid/entity.hh:854
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:153
Entity()
Definition: geometrygrid/entity.hh:771
Different resources needed by all grid implementations.
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:182
void initialize(const HostEntity &hostEntity)
initialize an entity
Definition: geometrygrid/entity.hh:286
LeafIntersectionIterator ileafbegin() const
Definition: geometrygrid/entity.hh:805
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:437
EntitySeedImp Implementation
type of underlying implementation
Definition: common/entityseed.hh:37
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:705
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:389
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:532
HierarchicIterator hbegin(int maxLevel) const
Definition: geometrygrid/entity.hh:842
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:698
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:488
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:763
Entity(const GeometryImpl &geo, HostEntity &&hostE)
Definition: geometrygrid/entity.hh:776
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:267
Entity(const GeometryImpl &geo, const HostEntity &hostE)
Definition: geometrygrid/entity.hh:775
bool hasFather() const
Definition: geometrygrid/entity.hh:832
Definition: geometrygrid/entity.hh:57
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:443
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:764
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:404
LevelIntersectionIterator ilevelend() const
Definition: geometrygrid/entity.hh:799
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:708
Entity()
Definition: geometrygrid/entity.hh:703
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:226
LeafIntersectionIterator ileafend() const
Definition: geometrygrid/entity.hh:811
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:413
all entities lying in the overlap zone
Definition: gridenums.hh:33
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:159
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:116
Include standard header files.
Definition: agrid.hh:59
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: geometrygrid/entity.hh:759
LevelIntersectionIterator ilevelbegin() const
Definition: geometrygrid/entity.hh:793
concept ReferenceElement
Definition: concepts/geometry.hh:18
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:101
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition: geometrygrid/entity.hh:710
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:122
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:765
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:592
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:165
bool mightVanish() const
Definition: geometrygrid/entity.hh:864
bool isNew() const
Definition: geometrygrid/entity.hh:859
Definition: cornerstorage.hh:22
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:125
Entity(const Grid &g, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:778
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: geometrygrid/entity.hh:757
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:207
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygrid/entity.hh:787
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition: geometrygrid/entity.hh:752
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:297
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:652
Wrapper class for entities.
Definition: common/entity.hh:65
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:119
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:462
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 >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: geometrygrid/entity.hh:750
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:261
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:407
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:276
Definition: geometrygrid/entity.hh:60
concept EntitySeed
Model of an entity seed.
Definition: concepts/entity.hh:25
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
void initialize(const HostElement &hostElement)
initialize an entity
Definition: geometrygrid/entity.hh:611
bool isLeaf() const
Definition: geometrygrid/entity.hh:822
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition: geometrygrid/entity.hh:147
Geometry geometry() const
Definition: geometrygrid/entity.hh:251
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: geometrygrid/entity.hh:755
EntityBase(const Grid &grid, const HostElement &hostElement, unsigned int subEntity)
Definition: geometrygrid/entity.hh:431