3 #ifndef DUNE_GEOGRID_ENTITY_HH
4 #define DUNE_GEOGRID_ENTITY_HH
6 #include <dune/common/nullptr.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 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;
104 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
108 typedef typename Traits::HostGrid HostGrid;
109 typedef typename Traits::CoordFunction CoordFunction;
115 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
121 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
124 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
127 typedef typename Traits::template Codim< codim >::GeometryImpl
GeometryImpl;
130 typedef typename HostGrid::template Codim< codimension >::Geometry HostGeometry;
145 : hostEntity_( grid.hostGrid().entity( grid.getRealImplementation(seed).hostEntitySeed() ) )
150 : hostEntity_( hostElement.template subEntity<codim>(i) )
156 : hostEntity_( hostEntity )
157 , grid_( &geo.grid() )
162 : hostEntity_( std::
move( hostEntity ) )
163 , grid_( &geo.grid() )
168 : hostEntity_( hostEntity )
173 : hostEntity_( std::
move( hostEntity ) )
179 : hostEntity_( other.hostEntity_ )
180 , grid_( other.grid_ )
185 : hostEntity_( std::
move( other.hostEntity_ ) )
186 , grid_( other.grid_ )
187 , geo_( std::
move( other.geo_ ) )
194 hostEntity_ = other.hostEntity_;
202 hostEntity_ =
std::move( other.hostEntity_ );
211 return hostEntity_ == other.hostEntity_;
224 return hostEntity().type();
230 return hostEntity().level();
236 return hostEntity().partitionType();
257 CoordVector coords( hostEntity(), grid().coordFunction() );
271 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
292 template<
class HostIndexSet >
293 typename HostIndexSet::IndexType
294 index (
const HostIndexSet &indexSet )
const
296 return indexSet.template index< codimension >( hostEntity() );
308 template<
class HostIndexSet >
309 typename HostIndexSet::IndexType
310 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
312 return indexSet.subIndex( hostEntity(), i, cd );
322 template<
class HostIndexSet >
325 return indexSet.contains( hostEntity() );
335 template<
class HostIdSet >
336 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
338 return idSet.template id< codimension >( hostEntity() );
343 HostEntity hostEntity_;
345 mutable GeometryImpl geo_;
360 template<
int codim,
class Gr
id >
363 typedef typename remove_const< Grid >::type::Traits Traits;
369 static const int codimension = codim;
372 static const int dimension = Traits::dimension;
374 static const int mydimension = dimension - codimension;
376 static const int dimensionworld = Traits::dimensionworld;
379 static const bool fake =
true;
385 typedef typename Traits::ctype
ctype;
389 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
393 typedef typename Traits::HostGrid HostGrid;
394 typedef typename Traits::CoordFunction CoordFunction;
400 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
406 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
409 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
412 typedef typename Traits::template Codim< codimension >::GeometryImpl
GeometryImpl;
415 typedef typename HostGrid::template Codim< 0 >::Geometry HostGeometry;
416 typedef typename HostGrid::template Codim< dimension >::EntityPointer HostVertexPointer;
428 : hostElement_( grid.hostGrid().entity( grid.getRealImplementation(seed).hostElementSeed() ) )
430 , subEntity_( grid.getRealImplementation(seed).subEntity() )
434 : geo_( other.geo_ ),
435 hostElement_( other.hostElement_ ),
436 subEntity_( other.subEntity_ )
440 : geo_( std::
move( other.geo_ ) ),
441 hostElement_( std::
move( other.hostElement_ ) ),
442 subEntity_( std::
move( other.subEntity_ ) )
450 hostElement_ = other.hostElement_;
451 subEntity_ = other.subEntity_;
458 hostElement_ =
std::move( other.hostElement_ );
459 subEntity_ =
std::move( other.subEntity_ );
466 const bool thisEnd = (subEntity() < 0);
467 const bool otherEnd = (other.subEntity() < 0);
468 if( thisEnd || otherEnd )
469 return thisEnd && otherEnd;
471 const int lvl = level();
472 if( lvl != other.level() )
475 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
476 = grid().hostGrid().levelIndexSet( lvl );
479 assert( indexSet.contains( thisElement ) );
480 const HostElement &otherElement = other.hostElement();
481 assert( indexSet.contains( otherElement ) );
483 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
484 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
485 return (thisIndex == otherIndex);
497 const ReferenceElement< ctype, dimension > &refElement
498 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
499 return refElement.type( subEntity_, codimension );
505 return hostElement().level();
514 const ReferenceElement< ctype, dimension > &refElement
515 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
521 const int numVertices = refElement.size( subEntity_, codimension, dimension );
522 for(
int i = 1; i < numVertices; ++i )
524 PartitionType vtxType = vertexPartitionType( refElement, i );
527 if( type != vtxType )
552 CoordVector coords( hostElement(), subEntity_, grid().coordFunction() );
565 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
569 DUNE_THROW( NotImplemented,
"HostGrid has no entities of codimension " << codimension <<
"." );
596 template<
class HostIndexSet >
597 typename HostIndexSet::IndexType
index (
const HostIndexSet &indexSet )
const
599 return indexSet.subIndex( hostElement(), subEntity_, codimension );
611 template<
class HostIndexSet >
612 typename HostIndexSet::IndexType
613 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
615 const ReferenceElement< ctype, dimension > &refElement
616 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
617 const int j = refElement.subEntity( subEntity_, codimension, i, codimension+cd );
618 return indexSet.subIndex( hostElement(), j, codimension+cd );
628 template<
class HostIndexSet >
631 return indexSet.contains( hostElement() );
641 template<
class HostIdSet >
642 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
644 return idSet.subId( hostElement(), subEntity_, codimension );
650 vertexPartitionType (
const ReferenceElement< ctype, dimension > &refElement,
int i )
const
652 const int j = refElement.subEntity( subEntity_, codimension, 0, dimension );
653 return hostElement().template subEntity< dimension >( j )->partitionType();
657 HostElement hostElement_;
658 unsigned int subEntity_;
660 mutable GeometryImpl geo_;
668 template<
int codim,
int dim,
class Gr
id >
670 :
public EntityBase< codim, Grid >
696 template<
int dim,
class Gr
id >
702 typedef typename remove_const< Grid >::type::Traits Traits;
704 typedef typename Traits::HostGrid HostGrid;
710 static const int codimension = Base::codimension;
713 static const int dimension = Base::dimension;
715 static const int mydimension = Base::mydimension;
717 static const int dimensionworld = Base::dimensionworld;
720 static const bool fake = Base::fake;
726 typedef typename Traits::template Codim< codimension >::LocalGeometry
LocalGeometry;
729 typedef typename Traits::template Codim< codimension >::EntityPointer
EntityPointer;
748 using Base::hostEntity;
764 template<
int codim >
767 return hostEntity().template count< codim >();
772 return hostEntity().subEntities(codim);
775 template<
int codim >
776 typename Grid::template Codim< codim >::Entity
779 typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
780 return EntityImpl( grid(), hostEntity(), i );
786 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelbegin() );
792 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelend() );
798 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafbegin() );
804 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafend() );
809 return hostEntity().hasBoundaryIntersections();
814 return hostEntity().isLeaf();
819 return Entity( grid(), hostEntity().father() );
824 return hostEntity().hasFather();
829 return hostEntity().geometryInFather();
835 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
841 return HierarchicIteratorImpl( grid(), hostEntity().hend( maxLevel ) );
846 return hostEntity().isRegular();
851 return hostEntity().isNew();
856 return hostEntity().mightVanish();
864 #endif // #ifndef DUNE_GEOGRID_ENTITY_HH
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:144
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:642
Entity()
Definition: geometrygrid/entity.hh:680
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:228
const Grid & grid() const
Definition: geometrygrid/entity.hh:271
on boundary between overlap and ghost
Definition: gridenums.hh:32
bool isLeaf() const
Definition: geometrygrid/entity.hh:812
LeafIntersectionIterator ileafbegin() const
Definition: geometrygrid/entity.hh:795
const HostElement & hostElement() const
Definition: geometrygrid/entity.hh:572
Definition: geometrygrid/entity.hh:57
bool mightVanish() const
Definition: geometrygrid/entity.hh:854
EntityBase()
Definition: geometrygrid/entity.hh:138
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:222
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:184
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:675
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:234
Different resources needed by all grid implementations.
Geometry geometry() const
Definition: geometrygrid/entity.hh:548
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: geometrygrid/entity.hh:738
bool hasBoundaryIntersections() const
Definition: geometrygrid/entity.hh:807
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:427
EntityBase()
Definition: geometrygrid/entity.hh:424
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:101
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:167
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:336
static void(*)(*)(*)(*)(*)(*) move(const double *)
Definition: partitiondisplay.cc:122
Entity(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:755
Wrapper class for entities.
Definition: common/entity.hh:61
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: geometrygrid/entity.hh:734
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:757
unsigned int subEntities(unsigned int codim) const
Definition: geometrygrid/entity.hh:770
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:682
bool hasFather() const
Definition: geometrygrid/entity.hh:822
int subEntity() const
Definition: geometrygrid/entity.hh:578
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:495
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition: geometrygrid/entity.hh:283
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:559
on boundary between interior and overlap
Definition: gridenums.hh:30
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:209
Definition: geometrygrid/entity.hh:60
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:104
bool isRegular() const
Definition: geometrygrid/entity.hh:844
all interior entities
Definition: gridenums.hh:29
HierarchicIterator hbegin(int maxLevel) const
Definition: geometrygrid/entity.hh:832
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:613
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:127
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:264
LeafIntersectionIterator ileafend() const
Definition: geometrygrid/entity.hh:801
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:629
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:464
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:178
Geometry geometry() const
Definition: geometrygrid/entity.hh:253
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:678
int count() const
Definition: geometrygrid/entity.hh:765
EntityFacade father() const
Definition: geometrygrid/entity.hh:817
EntitySeedImp Implementation
Export the implementation type.
Definition: common/entityseed.hh:31
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:503
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:310
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:744
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:685
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition: geometrygrid/entity.hh:149
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:116
Entity(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:754
Traits::template Codim< codimension >::EntityPointer EntityPointer
type of corresponding entity pointer
Definition: geometrygrid/entity.hh:729
Entity()
Definition: geometrygrid/entity.hh:750
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:323
HierarchicIterator hend(int maxLevel) const
Definition: geometrygrid/entity.hh:838
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: geometrygrid/entity.hh:403
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: geometrygrid/entity.hh:727
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:388
bool isNew() const
Definition: geometrygrid/entity.hh:849
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: geometrygrid/entity.hh:736
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:406
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:676
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition: geometrygrid/entity.hh:587
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:273
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition: geometrygrid/entity.hh:731
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition: geometrygrid/entity.hh:687
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:509
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: geometrygrid/entity.hh:118
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:684
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:743
LevelIntersectionIterator ilevelbegin() const
Definition: geometrygrid/entity.hh:783
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:597
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:752
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:172
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:401
all entities lying in the overlap zone
Definition: gridenums.hh:31
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:409
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:155
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:677
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:412
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:567
Specialize with 'true' if implementation supports parallelism. (default=false)
Definition: common/capabilities.hh:68
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:753
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:386
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:389
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:433
const Grid & grid() const
Definition: geometrygrid/entity.hh:565
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygrid/entity.hh:777
LocalGeometry geometryInFather() const
Definition: geometrygrid/entity.hh:827
LevelIntersectionIterator ilevelend() const
Definition: geometrygrid/entity.hh:789
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:124
Definition: cornerstorage.hh:20
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:294
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:742
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:439
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:161
Entity(const Grid &grid, const HostEntity &hostEntity, int i)
Definition: geometrygrid/entity.hh:759
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:745
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:121