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) )
155 EntityBase (
const GeometryImpl &geo,
const HostEntity &hostEntity )
156 : hostEntity_( hostEntity )
157 , grid_( &geo.grid() )
161 EntityBase (
const GeometryImpl &geo, HostEntity&& hostEntity )
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() );
258 geo_ = GeometryImpl( grid(), type(), coords );
260 return Geometry( geo_ );
271 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
283 void initialize (
const HostEntity &hostEntity ) { hostEntity_ = hostEntity; }
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 );
478 const HostElement &thisElement = hostElement();
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() );
553 geo_ = GeometryImpl( grid(), type(), coords );
555 return Geometry( geo_ );
565 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
569 DUNE_THROW( NotImplemented,
"HostGrid has no entities of codimension " << codimension <<
"." );
587 void initialize (
const HostElement &hostElement ) { hostElement_ = hostElement; }
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 >
682 Entity (
const Grid &grid,
const EntitySeed &seed ) : Base( grid, seed ) {}
684 Entity (
const Grid &grid,
const HostEntity &hostEntity ) : Base( grid, hostEntity ) {}
687 Entity (
const Grid &grid,
const HostElement &hostEntity,
int i ) : Base( grid, hostEntity, i ) {}
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;
752 Entity (
const Grid &grid,
const HostEntity &hostEntity ) : Base( grid, hostEntity ) {}
754 Entity (
const GeometryImpl &geo,
const HostEntity& hostEntity ) : Base( geo, hostEntity ) {}
755 Entity (
const GeometryImpl &geo, HostEntity &&hostEntity ) : Base( geo,
std::
move( hostEntity ) ) {}
757 Entity (
const Grid &grid,
const EntitySeed &seed ) : Base( grid, seed ) {}
759 Entity (
const Grid &grid,
const HostEntity &hostEntity,
int i ) : Base( grid, 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();
832 HierarchicIterator
hbegin (
int maxLevel )
const 835 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
838 HierarchicIterator
hend (
int maxLevel )
const 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 Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:101
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition: geometrygrid/entity.hh:149
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: geometrygrid/entity.hh:118
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: geometrygrid/entity.hh:403
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:743
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:336
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:406
bool hasBoundaryIntersections() const
Definition: geometrygrid/entity.hh:807
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:503
HierarchicIterator hbegin(int maxLevel) const
Definition: geometrygrid/entity.hh:832
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:155
bool hasFather() const
Definition: geometrygrid/entity.hh:822
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:509
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:323
Definition: geometrygrid/entity.hh:60
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:676
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:597
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:677
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:401
const Grid & grid() const
Definition: geometrygrid/entity.hh:271
Definition: cornerstorage.hh:20
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:409
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:209
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
EntityBase()
Definition: geometrygrid/entity.hh:138
on boundary between interior and overlap
Definition: gridenums.hh:30
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:753
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:752
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:567
Entity()
Definition: geometrygrid/entity.hh:750
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition: geometrygrid/entity.hh:731
Wrapper class for entities.
Definition: common/entity.hh:61
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:172
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
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: geometrygrid/entity.hh:738
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition: geometrygrid/entity.hh:587
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:127
Definition: geometrygrid/entity.hh:57
Entity()
Definition: geometrygrid/entity.hh:680
LeafIntersectionIterator ileafend() const
Definition: geometrygrid/entity.hh:801
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:273
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:124
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:757
Traits::template Codim< codimension >::EntityPointer EntityPointer
type of corresponding entity pointer
Definition: geometrygrid/entity.hh:729
bool isLeaf() const
Definition: geometrygrid/entity.hh:812
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:222
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:412
Entity(const Grid &grid, const HostEntity &hostEntity, int i)
Definition: geometrygrid/entity.hh:759
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:386
bool mightVanish() const
Definition: geometrygrid/entity.hh:854
LevelIntersectionIterator ilevelbegin() const
Definition: geometrygrid/entity.hh:783
const HostElement & hostElement() const
Definition: geometrygrid/entity.hh:572
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:389
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:161
Entity(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:754
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:121
all interior entities
Definition: gridenums.hh:29
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: geometrygrid/entity.hh:734
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:433
Geometry geometry() const
Definition: geometrygrid/entity.hh:548
EntityFacade father() const
Definition: geometrygrid/entity.hh:817
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: geometrygrid/entity.hh:736
const Grid & grid() const
Definition: geometrygrid/entity.hh:565
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: geometrygrid/entity.hh:727
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition: geometrygrid/entity.hh:687
bool isNew() const
Definition: geometrygrid/entity.hh:849
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:439
static void(*)(*)(*)(*)(*)(*) move(const double *)
Definition: partitiondisplay.cc:122
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
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:742
int count() const
Definition: geometrygrid/entity.hh:765
actual implementation of the entity
Definition: geometrygrid/entity.hh:34
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygrid/entity.hh:777
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:178
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:495
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:678
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
all entities lying in the overlap zone
Definition: gridenums.hh:31
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:744
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:745
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:264
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:427
LocalGeometry geometryInFather() const
Definition: geometrygrid/entity.hh:827
EntityBase()
Definition: geometrygrid/entity.hh:424
Include standard header files.
Definition: agrid.hh:59
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:184
Geometry geometry() const
Definition: geometrygrid/entity.hh:253
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:104
unsigned int subEntities(unsigned int codim) const
Definition: geometrygrid/entity.hh:770
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:234
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:682
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition: geometrygrid/entity.hh:283
EntitySeedImp Implementation
Export the implementation type.
Definition: common/entityseed.hh:31
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:675
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:684
Entity(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:755
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
bool isRegular() const
Definition: geometrygrid/entity.hh:844
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:629
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:685
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:294
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:464
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:167
int subEntity() const
Definition: geometrygrid/entity.hh:578
Different resources needed by all grid implementations.
LeafIntersectionIterator ileafbegin() const
Definition: geometrygrid/entity.hh:795
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:559
HierarchicIterator hend(int maxLevel) const
Definition: geometrygrid/entity.hh:838
DUNE-conform implementation of the entityThis class merely changes the template parameters of the ent...
Definition: geometrygrid/entity.hh:49
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:228
Specialize with 'true' if implementation supports parallelism. (default=false)
Definition: common/capabilities.hh:68
on boundary between overlap and ghost
Definition: gridenums.hh:32
LevelIntersectionIterator ilevelend() const
Definition: geometrygrid/entity.hh:789
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:116