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;
82 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;
99 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;
114 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() );
267 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
288 template<
class HostIndexSet >
289 typename HostIndexSet::IndexType
290 index (
const HostIndexSet &indexSet )
const
292 return indexSet.template index< codimension >( hostEntity() );
304 template<
class HostIndexSet >
305 typename HostIndexSet::IndexType
306 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
308 return indexSet.subIndex( hostEntity(), i, cd );
318 template<
class HostIndexSet >
321 return indexSet.contains( hostEntity() );
331 template<
class HostIdSet >
332 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
334 return idSet.template id< codimension >( hostEntity() );
339 HostEntity hostEntity_;
341 mutable GeometryImpl geo_;
356 template<
int codim,
class Gr
id >
359 typedef typename std::remove_const< Grid >::type::Traits Traits;
366 static const int codimension = codim;
368 static const int dimension = Traits::dimension;
370 static const int mydimension = dimension - codimension;
372 static const int dimensionworld = Traits::dimensionworld;
375 static const bool fake =
true;
382 typedef typename Traits::ctype
ctype;
385 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
389 typedef typename Traits::HostGrid HostGrid;
390 typedef typename Traits::CoordFunction CoordFunction;
397 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
400 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
403 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
406 typedef typename Traits::template Codim< codimension >::GeometryImpl
GeometryImpl;
409 typedef typename HostGrid::template Codim< 0 >::Geometry HostGeometry;
425 : hostElement_(hostElement)
426 , subEntity_(subEntity)
431 : hostElement_( grid.hostGrid().entity( grid.getRealImplementation(seed).hostElementSeed() ) )
432 , subEntity_( grid.getRealImplementation(seed).subEntity() )
437 : hostElement_( other.hostElement_ )
438 , subEntity_( other.subEntity_ )
444 : hostElement_(
std::move( other.hostElement_ ) )
445 , subEntity_(
std::move( other.subEntity_ ) )
446 , grid_(
std::move( other.grid_ ) )
447 , geo_(
std::move( other.geo_ ) )
457 DUNE_THROW(Dune::Exception,
"GeometryGrid: Cannot create fake entity of codim " << codimension <<
" from real host entity.");
464 hostElement_ = other.hostElement_;
465 subEntity_ = other.subEntity_;
473 hostElement_ = std::move( other.hostElement_ );
474 subEntity_ = std::move( other.subEntity_ );
475 grid_ = std::move( other.grid_ );
476 geo_ = std::move( other.geo_ );
483 const bool thisEnd = (subEntity() < 0);
484 const bool otherEnd = (other.subEntity() < 0);
485 if( thisEnd || otherEnd )
486 return thisEnd && otherEnd;
488 const int lvl = level();
489 if( lvl != other.level() )
492 const typename Traits::HostGrid::Traits::LevelIndexSet &indexSet
493 = grid().hostGrid().levelIndexSet( lvl );
496 assert( indexSet.contains( thisElement ) );
497 const HostElement &otherElement = other.hostElement();
498 assert( indexSet.contains( otherElement ) );
500 const int thisIndex = indexSet.subIndex( thisElement, subEntity(), codimension );
501 const int otherIndex = indexSet.subIndex( otherElement, other.subEntity(), codimension );
502 return (thisIndex == otherIndex);
514 const ReferenceElement< ctype, dimension > &refElement
515 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
516 return refElement.type( subEntity_, codimension );
522 return hostElement().level();
528 const ReferenceElement< ctype, dimension > &refElement
529 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
535 const int numVertices = refElement.size( subEntity_, codimension, dimension );
536 for(
int i = 1; i < numVertices; ++i )
538 PartitionType vtxType = vertexPartitionType( refElement, i );
541 if( type != vtxType )
566 CoordVector coords( hostElement(), subEntity_, grid().coordFunction() );
579 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
583 DUNE_THROW( NotImplemented,
"HostGrid has no entities of codimension " << codimension <<
"." );
609 template<
class HostIndexSet >
610 typename HostIndexSet::IndexType
index (
const HostIndexSet &indexSet )
const
612 return indexSet.subIndex( hostElement(), subEntity_, codimension );
624 template<
class HostIndexSet >
625 typename HostIndexSet::IndexType
626 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
628 const ReferenceElement< ctype, dimension > &refElement
629 = ReferenceElements< ctype, dimension >::general( hostElement().type() );
630 const int j = refElement.subEntity( subEntity_, codimension, i, codimension+cd );
631 return indexSet.subIndex( hostElement(), j, codimension+cd );
641 template<
class HostIndexSet >
644 return indexSet.contains( hostElement() );
654 template<
class HostIdSet >
655 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
657 return idSet.subId( hostElement(), subEntity_, codimension );
663 vertexPartitionType (
const ReferenceElement< ctype, dimension > &refElement,
int i )
const
665 const int j = refElement.subEntity( subEntity_, codimension, i, dimension );
666 return hostElement().template subEntity< dimension >( j ).partitionType();
670 HostElement hostElement_;
671 unsigned int subEntity_;
673 mutable GeometryImpl geo_;
681 template<
int codim,
int dim,
class Gr
id >
709 template<
int dim,
class Gr
id >
715 typedef typename std::remove_const< Grid >::type::Traits Traits;
717 typedef typename Traits::HostGrid HostGrid;
724 static const int codimension = Base::codimension;
726 static const int dimension = Base::dimension;
728 static const int mydimension = Base::mydimension;
730 static const int dimensionworld = Base::dimensionworld;
733 static const bool fake = Base::fake;
740 typedef typename Traits::template Codim< codimension >::LocalGeometry
LocalGeometry;
759 using Base::hostEntity;
775 template<
int codim >
778 return hostEntity().template count< codim >();
783 return hostEntity().subEntities(codim);
786 template<
int codim >
787 typename Grid::template Codim< codim >::Entity
790 typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
791 return EntityImpl( grid(), hostEntity(), i );
797 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelbegin() );
803 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelend() );
809 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafbegin() );
815 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafend() );
820 return hostEntity().hasBoundaryIntersections();
825 return hostEntity().isLeaf();
830 return Entity( grid(), hostEntity().father() );
835 return hostEntity().hasFather();
840 return hostEntity().geometryInFather();
846 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
852 return HierarchicIteratorImpl( grid(), hostEntity().hend( maxLevel ) );
857 return hostEntity().isRegular();
862 return hostEntity().isNew();
867 return hostEntity().mightVanish();
PartitionType
Attributes used in the generic overlap model.
Definition gridenums.hh:28
@ FrontEntity
on boundary between overlap and ghost
Definition gridenums.hh:32
@ BorderEntity
on boundary between interior and overlap
Definition gridenums.hh:30
@ OverlapEntity
all entities lying in the overlap zone
Definition gridenums.hh:31
Include standard header files.
Definition agrid.hh:60
Wrapper class for entities.
Definition common/entity.hh:62
EntitySeedImp Implementation
Export the implementation type.
Definition common/entityseed.hh:31
Grid abstract base class.
Definition common/grid.hh:373
Definition cornerstorage.hh:20
actual implementation of the entity
Definition geometrygrid/entity.hh:32
DUNE-conform implementation of the entity.
Definition geometrygrid/entity.hh:684
Entity(const Grid &grid, const EntitySeed &seed)
Definition geometrygrid/entity.hh:695
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:697
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition geometrygrid/entity.hh:698
Base::HostEntity HostEntity
Definition geometrygrid/entity.hh:688
Base::HostElement HostElement
Definition geometrygrid/entity.hh:689
Entity()
Definition geometrygrid/entity.hh:693
Base::GeometryImpl GeometryImpl
Definition geometrygrid/entity.hh:690
Base::EntitySeed EntitySeed
Definition geometrygrid/entity.hh:691
Entity(const Grid &grid, const HostElement &hostEntity, int i)
Definition geometrygrid/entity.hh:700
Definition iterator.hh:394
Definition geometrygrid/intersectioniterator.hh:19
GeometryType type() const
obtain the name of the corresponding reference element
Definition geometrygrid/entity.hh:218
EntityBase(const Grid &grid, const HostElement &hostElement, int i)
Definition geometrygrid/entity.hh:145
bool equals(const EntityBase &other) const
compare two entities
Definition geometrygrid/entity.hh:205
EntityBase(const Grid &grid, HostEntity &&hostEntity)
Definition geometrygrid/entity.hh:168
EntityBase(EntityBase &&other)
Definition geometrygrid/entity.hh:180
EntityBase()
Definition geometrygrid/entity.hh:134
Traits::ctype ctype
coordinate type of the grid
Definition geometrygrid/entity.hh:99
const HostEntity & hostEntity() const
Definition geometrygrid/entity.hh:269
EntityBase(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition geometrygrid/entity.hh:157
Geometry geometry() const
Definition geometrygrid/entity.hh:249
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition geometrygrid/entity.hh:279
EntitySeed seed() const
return EntitySeed of host grid entity
Definition geometrygrid/entity.hh:260
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition geometrygrid/entity.hh:332
Traits::template Codim< codim >::GeometryImpl GeometryImpl
Definition geometrygrid/entity.hh:123
EntityBase(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:151
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition geometrygrid/entity.hh:102
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition geometrygrid/entity.hh:114
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition geometrygrid/entity.hh:117
EntityBase(const EntityBase &other)
Definition geometrygrid/entity.hh:174
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:163
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition geometrygrid/entity.hh:290
const Grid & grid() const
Definition geometrygrid/entity.hh:267
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition geometrygrid/entity.hh:140
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition geometrygrid/entity.hh:120
PartitionType partitionType() const
obtain the partition type of this entity
Definition geometrygrid/entity.hh:230
int level() const
obtain the level of this entity
Definition geometrygrid/entity.hh:224
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:306
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition geometrygrid/entity.hh:319
EntityBase(const EntityBase &other)
Definition geometrygrid/entity.hh:436
int level() const
obtain the level of this entity
Definition geometrygrid/entity.hh:520
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition geometrygrid/entity.hh:403
EntityBase(EntityBase &&other)
Definition geometrygrid/entity.hh:443
const HostEntity & hostEntity() const
Definition geometrygrid/entity.hh:581
PartitionType partitionType() const
obtain the partition type of this entity
Definition geometrygrid/entity.hh:526
bool equals(const EntityBase &other) const
compare two entities
Definition geometrygrid/entity.hh:481
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition geometrygrid/entity.hh:610
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition geometrygrid/entity.hh:400
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition geometrygrid/entity.hh:385
EntityBase(const Grid &grid, const HostElement &hostElement, unsigned int subEntity)
Definition geometrygrid/entity.hh:424
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition geometrygrid/entity.hh:655
EntitySeed seed() const
return EntitySeed of host grid entity
Definition geometrygrid/entity.hh:573
EntityBase(const Grid &grid, const EntitySeed &seed)
Definition geometrygrid/entity.hh:430
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:626
Traits::template Codim< codimension >::GeometryImpl GeometryImpl
Definition geometrygrid/entity.hh:406
EntityBase(const Grid &grid, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:455
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition geometrygrid/entity.hh:600
const HostElement & hostElement() const
Definition geometrygrid/entity.hh:586
Geometry geometry() const
Definition geometrygrid/entity.hh:562
const Grid & grid() const
Definition geometrygrid/entity.hh:579
EntityBase()
Definition geometrygrid/entity.hh:417
Traits::ctype ctype
coordinate type of the grid
Definition geometrygrid/entity.hh:382
int subEntity() const
Definition geometrygrid/entity.hh:591
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition geometrygrid/entity.hh:642
GeometryType type() const
obtain the name of the corresponding reference element
Definition geometrygrid/entity.hh:512
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition geometrygrid/entity.hh:397
Dune::Entity< 0, dim, Grid, Dune::GeoGrid::Entity > EntityFacade
Definition geometrygrid/entity.hh:742
bool hasBoundaryIntersections() const
Definition geometrygrid/entity.hh:818
LevelIntersectionIterator ilevelend() const
Definition geometrygrid/entity.hh:800
bool isLeaf() const
Definition geometrygrid/entity.hh:823
bool isRegular() const
Definition geometrygrid/entity.hh:855
HierarchicIterator hbegin(int maxLevel) const
Definition geometrygrid/entity.hh:843
HierarchicIterator hend(int maxLevel) const
Definition geometrygrid/entity.hh:849
Entity(const GeometryImpl &geo, HostEntity &&hostEntity)
Definition geometrygrid/entity.hh:766
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition geometrygrid/entity.hh:745
Entity(const Grid &grid, const HostEntity &hostEntity, int i)
Definition geometrygrid/entity.hh:770
Entity(const Grid &grid, const EntitySeed &seed)
Definition geometrygrid/entity.hh:768
bool hasFather() const
Definition geometrygrid/entity.hh:833
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition geometrygrid/entity.hh:747
Grid::template Codim< codim >::Entity subEntity(int i) const
Definition geometrygrid/entity.hh:788
Entity(const Grid &grid, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:763
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition geometrygrid/entity.hh:749
Entity()
Definition geometrygrid/entity.hh:761
LeafIntersectionIterator ileafend() const
Definition geometrygrid/entity.hh:812
Entity(const GeometryImpl &geo, const HostEntity &hostEntity)
Definition geometrygrid/entity.hh:765
Base::HostEntity HostEntity
Definition geometrygrid/entity.hh:753
int count() const
Definition geometrygrid/entity.hh:776
LeafIntersectionIterator ileafbegin() const
Definition geometrygrid/entity.hh:806
bool isNew() const
Definition geometrygrid/entity.hh:860
LevelIntersectionIterator ilevelbegin() const
Definition geometrygrid/entity.hh:794
Base::EntitySeed EntitySeed
Definition geometrygrid/entity.hh:756
Base::HostElement HostElement
Definition geometrygrid/entity.hh:754
unsigned int subEntities(unsigned int codim) const
Definition geometrygrid/entity.hh:781
bool mightVanish() const
Definition geometrygrid/entity.hh:865
LocalGeometry geometryInFather() const
Definition geometrygrid/entity.hh:838
Entity(const Grid &grid, HostEntity &&hostEntity)
Definition geometrygrid/entity.hh:764
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition geometrygrid/entity.hh:740
EntityFacade father() const
Definition geometrygrid/entity.hh:828
Base::GeometryImpl GeometryImpl
Definition geometrygrid/entity.hh:755
Different resources needed by all grid implementations.