3#ifndef DUNE_GEOGRID_ENTITY_HH
4#define DUNE_GEOGRID_ENTITY_HH
8#include <dune/geometry/referenceelements.hh>
11#include <dune/grid/geometrygrid/capabilities.hh>
12#include <dune/grid/geometrygrid/cornerstorage.hh>
33 template<
int codim,
class Gr
id,
bool fake = !(Capabilities::hasHostEntity< Gr
id, codim >::v) >
48 template<
int codim,
int dim,
class Gr
id >
56 template<
class Gr
id >
57 class HierarchicIterator;
59 template<
class Gr
id,
class HostIntersectionIterator >
60 class IntersectionIterator;
74 template<
int codim,
class Gr
id >
84 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;
101 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;
116 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;
132 typedef GeoGrid::CoordVector< mydimension, Grid, fake > CoordVector;
146 hostEntity_( nullptr )
157 hostEntity_( nullptr )
161 : geo_( other.geo_ ),
162 hostEntity_( nullptr )
167 const EntityBase &operator= (
const EntityBase &other )
170 hostEntity_ =
nullptr;
174 operator bool ()
const {
return bool( hostEntity_ ); }
186 return hostEntity().type();
192 return hostEntity().level();
198 return hostEntity().partitionType();
219 CoordVector coords( hostEntity(), grid().coordFunction() );
220 geo_ = GeometryImpl( grid(), type(), coords );
233 const Grid &grid ()
const {
return geo_.grid(); }
235 const HostEntity &hostEntity ()
const
257 template<
class HostIndexSet >
258 typename HostIndexSet::IndexType
259 index (
const HostIndexSet &indexSet )
const
261 return indexSet.template index< codimension >( hostEntity() );
273 template<
class HostIndexSet >
274 typename HostIndexSet::IndexType
275 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
277 return indexSet.subIndex( hostEntity(), i, cd );
287 template<
class HostIndexSet >
290 return indexSet.contains( hostEntity() );
300 template<
class HostIdSet >
301 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
303 return idSet.template id< codimension >( hostEntity() );
308 mutable GeometryImpl geo_;
309 const HostEntity *hostEntity_;
324 template<
int codim,
class Gr
id >
334 static const int codimension = codim;
336 static const int dimension = Traits::dimension;
338 static const int mydimension = dimension - codimension;
340 static const int dimensionworld = Traits::dimensionworld;
343 static const bool fake =
true;
350 typedef typename Traits::ctype
ctype;
353 typedef typename Traits::template Codim< codimension >::Geometry
Geometry;
357 typedef typename Traits::HostGrid HostGrid;
358 typedef typename Traits::CoordFunction CoordFunction;
365 typedef typename HostGrid::template Codim< codimension >::Entity
HostEntity;
370 typedef typename Traits::template Codim< codimension >::EntitySeed
EntitySeed;
373 typedef typename HostGrid::template Codim< 0 >::Entity
HostElement;
376 typedef typename Traits::template Codim< codimension >::GeometryImpl GeometryImpl;
379 typedef typename HostGrid::template Codim< 0 >::Geometry HostGeometry;
380 typedef typename HostGrid::template Codim< dimension >::EntityPointer HostVertexPointer;
382 typedef GeoGrid::CoordVector< mydimension, Grid, fake > CoordVector;
397 hostElement_( nullptr ),
398 subEntity_( subEntity )
410 hostElement_( nullptr ),
411 subEntity_( subEntity )
415 : geo_( other.geo_ ),
416 hostElement_( nullptr ),
417 subEntity_( other.subEntity_ )
422 const EntityBase &operator= (
const EntityBase &other )
425 hostElement_ =
nullptr;
426 subEntity_ = other.subEntity_;
430 operator bool ()
const {
return bool( hostElement_ ); }
443 return refElement.
type( subEntity_, codimension );
449 return hostElement().level();
465 const int numVertices = refElement.
size( subEntity_, codimension, dimension );
466 for(
int i = 1; i < numVertices; ++i )
468 PartitionType vtxType = vertexPartitionType( refElement, i );
471 if( type != vtxType )
496 CoordVector coords( hostElement(), subEntity_, grid().coordFunction() );
497 geo_ = GeometryImpl( grid(), type(), coords );
509 const Grid &grid ()
const {
return geo_.grid(); }
511 const HostEntity &hostEntity ()
const
516 const HostElement &hostElement ()
const
519 return *hostElement_;
522 int subEntity ()
const {
return subEntity_; }
540 template<
class HostIndexSet >
541 typename HostIndexSet::IndexType
index (
const HostIndexSet &indexSet )
const
543 return indexSet.subIndex( hostElement(), subEntity_, codimension );
555 template<
class HostIndexSet >
556 typename HostIndexSet::IndexType
557 subIndex (
const HostIndexSet &indexSet,
int i,
unsigned int cd )
const
561 const int j = refElement.
subEntity( subEntity_, codimension, i, codimension+cd );
562 return indexSet.subIndex( hostElement(), j, codimension+cd );
572 template<
class HostIndexSet >
575 return indexSet.contains( hostElement() );
585 template<
class HostIdSet >
586 typename HostIdSet::IdType
id (
const HostIdSet &idSet )
const
588 return idSet.subId( hostElement(), subEntity_, codimension );
596 const int j = refElement.
subEntity( subEntity_, codimension, 0, dimension );
597 return hostElement().template subEntity< dimension >( j )->partitionType();
601 mutable GeometryImpl geo_;
602 const HostElement *hostElement_;
603 unsigned int subEntity_;
611 template<
int codim,
int dim,
class Gr
id >
618 typedef typename Base::HostEntity HostEntity;
619 typedef typename Base::HostElement HostElement;
620 typedef typename Base::GeometryImpl GeometryImpl;
626 explicit Entity (
const GeometryImpl &geo )
631 :
Base( grid, subEntity )
634 Entity (
const GeometryImpl &geo,
int subEntity )
635 :
Base( geo, subEntity )
644 template<
int dim,
class Gr
id >
652 typedef typename Traits::HostGrid HostGrid;
659 static const int codimension = Base::codimension;
661 static const int dimension = Base::dimension;
663 static const int mydimension = Base::mydimension;
665 static const int dimensionworld = Base::dimensionworld;
668 static const bool fake = Base::fake;
675 typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
677 typedef typename Traits::template Codim< codimension >::EntityPointer EntityPointer;
680 typedef typename Traits::HierarchicIterator HierarchicIterator;
682 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
684 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
688 typedef typename Base::HostEntity HostEntity;
689 typedef typename Base::HostElement HostElement;
690 typedef typename Base::GeometryImpl GeometryImpl;
693 using Base::hostEntity;
699 explicit Entity (
const GeometryImpl &geo )
703 template<
int codim >
706 return hostEntity().template count< codim >();
709 template<
int codim >
710 typename Grid::template Codim< codim >::EntityPointer
711 subEntity (
int i )
const
713 typedef typename Traits::template Codim< codim >::EntityPointerImpl EntityPointerImpl;
714 return EntityPointerImpl( grid(), hostEntity(), i );
717 LevelIntersectionIterator ilevelbegin ()
const
719 typedef GeoGrid::IntersectionIterator< Grid, typename HostGrid::LevelIntersectionIterator > LevelIntersectionIteratorImpl;
720 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelbegin() );
723 LevelIntersectionIterator ilevelend ()
const
725 typedef GeoGrid::IntersectionIterator< Grid, typename HostGrid::LevelIntersectionIterator > LevelIntersectionIteratorImpl;
726 return LevelIntersectionIteratorImpl( *
this, hostEntity().ilevelend() );
729 LeafIntersectionIterator ileafbegin ()
const
731 typedef GeoGrid::IntersectionIterator< Grid, typename HostGrid::LeafIntersectionIterator > LeafIntersectionIteratorImpl;
732 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafbegin() );
735 LeafIntersectionIterator ileafend ()
const
737 typedef GeoGrid::IntersectionIterator< Grid, typename HostGrid::LeafIntersectionIterator > LeafIntersectionIteratorImpl;
738 return LeafIntersectionIteratorImpl( *
this, hostEntity().ileafend() );
741 bool hasBoundaryIntersections ()
const
743 return hostEntity().hasBoundaryIntersections();
748 return hostEntity().isLeaf();
751 EntityPointer father ()
const
753 typedef typename Traits::template Codim< 0 >::EntityPointerImpl EntityPointerImpl;
754 return EntityPointerImpl( grid(), hostEntity().father() );
757 bool hasFather ()
const
759 return hostEntity().hasFather();
762 LocalGeometry geometryInFather ()
const
764 return hostEntity().geometryInFather();
767 HierarchicIterator hbegin (
int maxLevel )
const
769 typedef GeoGrid::HierarchicIterator< Grid > HierarchicIteratorImpl;
770 return HierarchicIteratorImpl( grid(), hostEntity().hbegin( maxLevel ) );
773 HierarchicIterator hend (
int maxLevel )
const
775 typedef GeoGrid::HierarchicIterator< Grid > HierarchicIteratorImpl;
776 return HierarchicIteratorImpl( grid(), hostEntity().hend( maxLevel ) );
779 bool isRegular ()
const
781 return hostEntity().isRegular();
786 return hostEntity().isNew();
789 bool mightVanish ()
const
791 return hostEntity().mightVanish();
EntitySeedImp Implementation
Export the implementation type.
Definition: entityseed.hh:31
Wrapper class for entities.
Definition: entity.hh:57
GeometryType type() const
obtain the name of the corresponding reference element
Definition: entity.hh:184
EntityBase(const GeometryImpl &geo)
construct an uninitialized entity
Definition: entity.hh:155
EntityBase(const Grid &grid)
construct an uninitialized entity
Definition: entity.hh:144
Traits::ctype ctype
coordinate type of the grid
Definition: entity.hh:101
Geometry geometry() const
Definition: entity.hh:215
void initialize(const HostEntity &hostEntity)
initiliaze an entity
Definition: entity.hh:248
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: entity.hh:226
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: entity.hh:301
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: entity.hh:118
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: entity.hh:104
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: entity.hh:116
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: entity.hh:121
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: entity.hh:259
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: entity.hh:124
PartitionType partitionType() const
obtain the partition type of this entity
Definition: entity.hh:196
int level() const
obtain the level of this entity
Definition: entity.hh:190
HostIndexSet::IndexType subIndex(const HostIndexSet &indexSet, int i, unsigned int cd) const
obtain the index of a subentity from a host IndexSet
Definition: entity.hh:275
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: entity.hh:288
int level() const
obtain the level of this entity
Definition: entity.hh:447
HostGrid::template Codim< 0 >::Entity HostElement
type of host elements, i.e., of host entities of codimension 0
Definition: entity.hh:373
PartitionType partitionType() const
obtain the partition type of this entity
Definition: entity.hh:453
HostIndexSet::IndexType index(const HostIndexSet &indexSet) const
obtain the entity's index from a host IndexSet
Definition: entity.hh:541
Traits::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition: entity.hh:370
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition: entity.hh:353
HostGrid::template Codim< codimension >::EntityPointer HostEntityPointer
type of corresponding host entity pointer
Definition: entity.hh:367
HostIdSet::IdType id(const HostIdSet &idSet) const
obtain the entity's id from a host IdSet
Definition: entity.hh:586
EntitySeed seed() const
return EntitySeed of host grid entity
Definition: 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: entity.hh:557
void initialize(const HostElement &hostElement)
initiliaze an entity
Definition: entity.hh:531
EntityBase(const GeometryImpl &geo, int subEntity)
construct an uninitialized entity
Definition: entity.hh:408
Geometry geometry() const
Definition: entity.hh:492
Traits::ctype ctype
coordinate type of the grid
Definition: entity.hh:350
bool isContained(const HostIndexSet &indexSet) const
check whether the entity is contained in a host index set
Definition: entity.hh:573
GeometryType type() const
obtain the name of the corresponding reference element
Definition: entity.hh:439
HostGrid::template Codim< codimension >::Entity HostEntity
type of corresponding host entity
Definition: entity.hh:365
EntityBase(const Grid &grid, int subEntity)
construct an uninitialized entity
Definition: entity.hh:395
actual implementation of the entity
Definition: entity.hh:34
DUNE-conform implementation of the entity.
Definition: entity.hh:614
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Grid abstract base class.
Definition: grid.hh:386
Default exception for dummy implementations.
Definition: exceptions.hh:289
This class provides access to geometric and topological properties of a reference element....
Definition: referenceelements.hh:58
int size(int c) const
number of subentities of codimension c
Definition: referenceelements.hh:86
int subEntity(int i, int c, int ii, int cc) const
obtain number of ii-th subentity with codim cc of (i,c)
Definition: referenceelements.hh:122
const GeometryType & type(int i, int c) const
obtain the type of subentity (i,c)
Definition: referenceelements.hh:136
Different resources needed by all grid implementations.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Dune namespace.
Definition: alignment.hh:14
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
@ FrontEntity
on boundary between overlap and ghost
Definition: gridenums.hh:28
@ InteriorEntity
all interior entities
Definition: gridenums.hh:25
@ BorderEntity
on boundary between interior and overlap
Definition: gridenums.hh:26
@ OverlapEntity
all entities lying in the overlap zone
Definition: gridenums.hh:27
Fallback implementation of the nullptr object in C++0x.
Specialize with 'true' if implementation supports parallelism. (default=false)
Definition: capabilities.hh:65
static const ReferenceElement< ctype, dim > & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:568
Removes a const qualifier while preserving others.
Definition: typetraits.hh:176