Go to the documentation of this file.
3 #ifndef DUNE_GEOGRID_ENTITY_HH
4 #define DUNE_GEOGRID_ENTITY_HH
6 #include <dune/geometry/referenceelements.hh>
31 template<
int codim,
class Gr
id,
bool fake = !(Capabilities::hasHostEntity< Gr
id, codim >::v) >
46 template<
int codim,
int dim,
class Gr
id >
54 template<
class Gr
id >
57 template<
class Gr
id,
class HostIntersectionIterator >
72 template<
int codim,
class Gr
id >
75 typedef typename std::remove_const< Grid >::type::Traits Traits;
81 static const int codimension = codim;
84 static const int dimension = Traits::dimension;
86 static const int mydimension = dimension - codimension;
88 static const int dimensionworld = Traits::dimensionworld;
91 static const bool fake =
false;
98 typedef typename Traits::ctype
ctype;
102 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
106 typedef typename Traits::HostGrid HostGrid;
107 typedef typename Traits::CoordFunction CoordFunction;
113 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
117 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
120 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
123 typedef typename Traits::template Codim< codim >::GeometryImpl
GeometryImpl;
126 typedef typename HostGrid::template Codim< codimension >::Geometry HostGeometry;
141 : hostEntity_( grid.hostGrid().entity( grid.getRealImplementation(seed).hostEntitySeed() ) )
146 : hostEntity_( hostElement.template subEntity<codim>(i) )
152 : hostEntity_( hostEntity )
153 , grid_( &geo.grid() )
158 : hostEntity_( std::move( hostEntity ) )
159 , grid_( &geo.grid() )
164 : hostEntity_( hostEntity )
169 : hostEntity_( std::move( hostEntity ) )
175 : hostEntity_( other.hostEntity_ )
176 , grid_( other.grid_ )
181 : hostEntity_( std::move( other.hostEntity_ ) )
182 , grid_( other.grid_ )
183 , geo_( std::move( other.geo_ ) )
190 hostEntity_ = other.hostEntity_;
198 hostEntity_ = std::move( other.hostEntity_ );
199 grid_ = std::move( other.grid_ );
200 geo_ = std::move( other.geo_ );
207 return hostEntity_ == other.hostEntity_;
220 return hostEntity().type();
226 return hostEntity().level();
232 return hostEntity().partitionType();
253 CoordVector coords( hostEntity(), grid().coordFunction() );
261 return hostEntity().subEntities( cc );
272 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
293 template<
class HostIndexSet >
294 typename HostIndexSet::IndexType
295 index (
const HostIndexSet &indexSet )
const
297 return indexSet.template index< codimension >( hostEntity() );
309 template<
class HostIndexSet >
310 typename HostIndexSet::IndexType
311 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
313 return indexSet.subIndex( hostEntity(), i, cd );
323 template<
class HostIndexSet >
326 return indexSet.contains( hostEntity() );
336 template<
class HostIdSet >
337 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
339 return idSet.template id< codimension >( hostEntity() );
344 HostEntity hostEntity_;
346 mutable GeometryImpl geo_;
361 template<
int codim,
class Gr
id >
364 typedef typename std::remove_const< Grid >::type::Traits Traits;
370 static const int codimension = codim;
373 static const int dimension = Traits::dimension;
375 static const int mydimension = dimension - codimension;
377 static const int dimensionworld = Traits::dimensionworld;
380 static const bool fake =
true;
386 typedef typename Traits::ctype
ctype;
390 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
394 typedef typename Traits::HostGrid HostGrid;
395 typedef typename Traits::CoordFunction CoordFunction;
401 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
405 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
408 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
411 typedef typename Traits::template Codim< codimension >::GeometryImpl
GeometryImpl;
414 typedef typename HostGrid::template Codim< 0 >::Geometry HostGeometry;
430 : hostElement_(hostElement)
431 , subEntity_(subEntity)
436 : hostElement_( grid.hostGrid().entity( grid.getRealImplementation(seed).hostElementSeed() ) )
437 , subEntity_( grid.getRealImplementation(seed).subEntity() )
442 : hostElement_( other.hostElement_ )
443 , subEntity_( other.subEntity_ )
449 : hostElement_( std::move( other.hostElement_ ) )
450 , subEntity_( std::move( other.subEntity_ ) )
451 , grid_( std::move( other.grid_ ) )
452 , geo_( std::move( other.geo_ ) )
462 DUNE_THROW(Dune::Exception,
"GeometryGrid: Cannot create fake entity of codim " << codimension <<
" from real host entity.");
469 hostElement_ = other.hostElement_;
470 subEntity_ = other.subEntity_;
478 hostElement_ = std::move( other.hostElement_ );
479 subEntity_ = std::move( other.subEntity_ );
480 grid_ = std::move( other.grid_ );
481 geo_ = std::move( other.geo_ );
488 const bool thisEnd = (subEntity() < 0);
489 const bool otherEnd = (other.subEntity() < 0);
490 if( thisEnd || otherEnd )
491 return thisEnd && otherEnd;
493 const int lvl = level();
494 if( lvl != other.level() )
497 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
498 = grid().hostGrid().levelIndexSet( lvl );
501 assert( indexSet.contains( thisElement ) );
502 const HostElement &otherElement = other.hostElement();
503 assert( indexSet.contains( otherElement ) );
505 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
506 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
507 return (thisIndex == otherIndex);
519 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
520 return refElement.type( subEntity_, codimension );
526 return hostElement().level();
532 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
538 const int numVertices = refElement.size( subEntity_, codimension, dimension );
539 for(
int i = 1; i < numVertices; ++i )
541 PartitionType vtxType = vertexPartitionType( refElement, i );
544 if( type != vtxType )
569 CoordVector coords( hostElement(), subEntity_, grid().coordFunction() );
577 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
578 return refElement.size( subEntity_, codimension, cc );
588 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
592 DUNE_THROW( NotImplemented,
"HostGrid has no entities of codimension " << codimension <<
"." );
618 template<
class HostIndexSet >
619 typename HostIndexSet::IndexType
index (
const HostIndexSet &indexSet )
const
621 return indexSet.subIndex( hostElement(), subEntity_, codimension );
633 template<
class HostIndexSet >
634 typename HostIndexSet::IndexType
635 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
637 auto refElement = referenceElement< ctype, dimension >( hostElement().type() );
638 const int j = refElement.subEntity( subEntity_, codimension, i, codimension+cd );
639 return indexSet.subIndex( hostElement(), j, codimension+cd );
649 template<
class HostIndexSet >
652 return indexSet.contains( hostElement() );
662 template<
class HostIdSet >
663 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
665 return idSet.subId( hostElement(), subEntity_, codimension );
671 vertexPartitionType ( Dune::Transitional::ReferenceElement< ctype, Dim<dimension> > refElement,
int i )
const
673 const int j = refElement.subEntity( subEntity_, codimension, i, dimension );
674 return hostElement().template subEntity< dimension >( j ).partitionType();
678 HostElement hostElement_;
679 unsigned int subEntity_;
681 mutable GeometryImpl geo_;
689 template<
int codim,
int dim,
class Gr
id >
691 :
public EntityBase< codim, Grid >
693 typedef EntityBase< codim, Grid > Base;
717 template<
int dim,
class Gr
id >
723 typedef typename std::remove_const< Grid >::type::Traits Traits;
725 typedef typename Traits::HostGrid HostGrid;
731 static const int codimension = Base::codimension;
734 static const int dimension = Base::dimension;
736 static const int mydimension = Base::mydimension;
738 static const int dimensionworld = Base::dimensionworld;
741 static const bool fake = Base::fake;
747 typedef typename Traits::template Codim< codimension >::LocalGeometry
LocalGeometry;
767 using Base::hostEntity;
783 template<
int codim >
784 typename Grid::template Codim< codim >::Entity
787 typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
788 return EntityImpl( grid(), hostEntity(), i );
794 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelbegin() );
800 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelend() );
806 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafbegin() );
812 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafend() );
817 return hostEntity().hasBoundaryIntersections();
822 return hostEntity().isLeaf();
827 return Entity( grid(), hostEntity().father() );
832 return hostEntity().hasFather();
837 return hostEntity().geometryInFather();
843 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
849 return HierarchicIteratorImpl( grid(), hostEntity().hend( maxLevel ) );
854 return hostEntity().isRegular();
859 return hostEntity().isNew();
864 return hostEntity().mightVanish();
872 #endif // #ifndef DUNE_GEOGRID_ENTITY_HH
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:311
Wrapper class for entities.
Definition: common/entity.hh:63
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:705
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition: geometrygrid/entity.hh:750
Different resources needed by all grid implementations.
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:324
Definition: cornerstorage.hh:20
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition: geometrygrid/entity.hh:753
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:140
int subEntity() const
Definition: geometrygrid/entity.hh:600
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:102
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:387
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:524
actual implementation of the entity
Definition: geometrygrid/entity.hh:32
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:776
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:174
EntityBase(const Grid &grid, const HostElement &hostElement, unsigned int subEntity)
Definition: geometrygrid/entity.hh:429
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:582
Geometry geometry() const
Definition: geometrygrid/entity.hh:249
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:114
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:163
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: geometrygrid/entity.hh:265
Grid abstract base class.
Definition: common/grid.hh:373
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: geometrygrid/entity.hh:650
bool isRegular() const
Definition: geometrygrid/entity.hh:852
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: geometrygrid/entity.hh:402
bool isNew() const
Definition: geometrygrid/entity.hh:857
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:274
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:31
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:411
Definition: geometrygrid/entity.hh:55
Entity(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:773
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:120
int level() const
obtain the level of this entity
Definition: geometrygrid/entity.hh:224
Entity()
Definition: geometrygrid/entity.hh:769
HierarchicIterator hend(int maxLevel) const
Definition: geometrygrid/entity.hh:846
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:696
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:697
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:295
EntityBase(const EntityBase &other)
Definition: geometrygrid/entity.hh:441
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:230
EntityFacade father() const
Definition: geometrygrid/entity.hh:825
const Grid & grid() const
Definition: geometrygrid/entity.hh:588
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:699
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:157
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:151
LeafIntersectionIterator ileafbegin() const
Definition: geometrygrid/entity.hh:803
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:635
Entity()
Definition: geometrygrid/entity.hh:701
DUNE-conform implementation of the entity.
Definition: geometrygrid/entity.hh:47
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition: geometrygrid/entity.hh:748
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:180
Entity(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:774
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition: geometrygrid/entity.hh:755
bool hasFather() const
Definition: geometrygrid/entity.hh:830
Entity(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:703
Base::HostElement HostElement
Definition: geometrygrid/entity.hh:762
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:575
HierarchicIterator hbegin(int maxLevel) const
Definition: geometrygrid/entity.hh:840
const HostEntity & hostEntity() const
Definition: geometrygrid/entity.hh:590
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:460
Base::EntitySeed EntitySeed
Definition: geometrygrid/entity.hh:764
const HostElement & hostElement() const
Definition: geometrygrid/entity.hh:595
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:772
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: geometrygrid/entity.hh:390
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:218
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition: geometrygrid/entity.hh:708
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:405
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:123
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:205
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:663
Base::HostEntity HostEntity
Definition: geometrygrid/entity.hh:761
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition: geometrygrid/entity.hh:435
LevelIntersectionIterator ilevelbegin() const
Definition: geometrygrid/entity.hh:791
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:706
Entity(const Grid &grid, const HostEntity &hostEntity, int i)
Definition: geometrygrid/entity.hh:778
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:28
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition: geometrygrid/entity.hh:168
bool mightVanish() const
Definition: geometrygrid/entity.hh:862
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition: geometrygrid/entity.hh:284
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition: geometrygrid/entity.hh:145
LevelIntersectionIterator ilevelend() const
Definition: geometrygrid/entity.hh:797
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:698
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: geometrygrid/entity.hh:619
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: geometrygrid/entity.hh:117
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:30
EntityBase(EntityBase &&other)
Definition: geometrygrid/entity.hh:448
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition: geometrygrid/entity.hh:609
@ FrontEntity
on boundary between overlap and ghost
Definition: gridenums.hh:32
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition: geometrygrid/entity.hh:785
PartitionType partitionType() const
obtain the partition type of this entity
Definition: geometrygrid/entity.hh:530
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition: geometrygrid/entity.hh:771
Geometry geometry() const
Definition: geometrygrid/entity.hh:565
EntitySeedImp Implementation
type of underlying implementation
Definition: common/entityseed.hh:35
LocalGeometry geometryInFather() const
Definition: geometrygrid/entity.hh:835
LeafIntersectionIterator ileafend() const
Definition: geometrygrid/entity.hh:809
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition: geometrygrid/entity.hh:757
const Grid & grid() const
Definition: geometrygrid/entity.hh:272
GeometryType type() const
obtain the name of the corresponding reference element
Definition: geometrygrid/entity.hh:517
bool equals(const EntityBase &other) const
compare two entities
Definition: geometrygrid/entity.hh:486
Definition: geometrygrid/entity.hh:58
bool isLeaf() const
Definition: geometrygrid/entity.hh:820
Include standard header files.
Definition: agrid.hh:58
Base::GeometryImpl GeometryImpl
Definition: geometrygrid/entity.hh:763
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: geometrygrid/entity.hh:337
Traits::ctype ctype
coordinate type of the grid
Definition: geometrygrid/entity.hh:99
EntityBase()
Definition: geometrygrid/entity.hh:422
unsigned int subEntities(unsigned int cc) const
Definition: geometrygrid/entity.hh:259
EntityBase()
Definition: geometrygrid/entity.hh:134
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: geometrygrid/entity.hh:408
bool hasBoundaryIntersections() const
Definition: geometrygrid/entity.hh:815