dune-grid  2.5-git
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Dune::EntityPointer< GridImp, IteratorImp > Class Template Reference

Wrapper class for pointers to entities. More...

#include <dune/grid/common/entitypointer.hh>

Inheritance diagram for Dune::EntityPointer< GridImp, IteratorImp >:
Inheritance graph

Classes

struct  Codim
 EntityPointer types of the different codimensions. More...
 

Public Types

enum  { codimension = IteratorImp::codimension }
 codimension of entity pointer More...
 
typedef IteratorImp::Entity Entity
 The Entity that this EntityPointer can point to. More...
 
typedef std::conditional< std::is_lvalue_reference< decltype(realIterator.dereference()) >::value, const Entity &, Entity >::type Reference
 Tpy of the reference used when derefencing the Ptr. More...
 

Public Member Functions

DUNE_ENTITYPOINTER_DEPRECATED_MSG bool operator== (const Entity &rhs) const
 Compares an EntityPointer with an Entity for equality. More...
 
DUNE_ENTITYPOINTER_DEPRECATED_MSG bool operator!= (const Entity &rhs) const
 Compares an EntityPointer with an Entity for inequality. More...
 
Constructor & conversion
template<class ItImp >
 EntityPointer (const EntityPointer< GridImp, ItImp > &ep)
 Templatized copy constructor from arbitrary IteratorImp. This enables that an EntityPointer can be copy-constructed from LevelIterator, LeafIterator and HierarchicIterator (because these are derived from EntityPointer<...> with their corresponding implementation. More...
 
 EntityPointer ()
 Default constructor of an empty (undefined) EntityPointer. More...
 
DUNE_ENTITYPOINTER_DEPRECATED_MSG EntityPointer (const Entity &entity)
 Templatized constructor from type of entity that this entity pointer points to. This constructor can be used to create an entity pointer from an entity in order to store an entity. The implementation of EntityPointer has to have a constructor taking a Dune::Entity. More...
 
 EntityPointer (const typename Entity::Implementation &entityImp)
 Constructor from type of entity implementation that this entity pointer points to. This constructor is only used in the EntityDefaultImplementation to implement the method seed() by default when the type of EntitySeed and EntityPointer coniside. More...
 
template<class ItImp >
DUNE_ENTITYPOINTER_DEPRECATED_MSG EntityPointeroperator= (const EntityPointer< GridImp, ItImp > &ep)
 
Dereferencing
Entity operator* () const DUNE_ENTITYPOINTER_DEPRECATED_MSG
 Dereferencing operator. More...
 
const Entityoperator-> () const DUNE_ENTITYPOINTER_DEPRECATED_MSG
 Pointer operator. More...
 
Compare methods
template<class ItImp >
bool operator== (const EntityPointer< GridImp, ItImp > &rhs) const
 Checks for equality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer. More...
 
template<class ItImp >
bool operator!= (const EntityPointer< GridImp, ItImp > &rhs) const
 Checks for inequality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer. More...
 
Query methods
int level () const DUNE_ENTITYPOINTER_DEPRECATED_MSG
 Ask for level of entity. More...
 
Implementor interface
 EntityPointer (const IteratorImp &i)
 Copy Constructor from an Iterator implementation. More...
 
template<class ItImp >
bool equals (const EntityPointer< GridImp, ItImp > &rhs) const
 Forward equality check to realIterator. More...
 

Protected Types

typedef IteratorImp Implementation
 

Protected Member Functions

Implementationimpl ()
 return reference to the real implementation More...
 
const Implementationimpl () const
 return reference to the real implementation More...
 

Protected Attributes

Implementation realIterator
 

Methods and Types of the Entity interface. These are here just for transition purpose

enum  { dimension =Entity::dimension }
 
enum  { mydimension =Entity::dimension }
 
typedef GridImp::template Codim< codimension >::Geometry Geometry
 The geometry type of this entity. More...
 
typedef GridImp::template Codim< codimension >::EntitySeed EntitySeed
 The corresponding entity seed (for storage of entities) More...
 
typedef GridImp::template Codim< codimension >::LocalGeometry LocalGeometry
 The geometry type of this entity when the geometry is expressed embedded in the father element. More...
 
typedef GridImp::HierarchicIterator HierarchicIterator
 The codim==0 EntityPointer type. More...
 
PartitionType partitionType () const
 Partition type of this entity. More...
 
Geometry geometry () const
 obtain geometric realization of the entity More...
 
GeometryType type () const
 Return the name of the reference element. The type can be used to access the Dune::ReferenceElement. More...
 
EntitySeed seed () const
 Return the entity seed which contains sufficient information to generate the entity again and uses as little memory as possible. More...
 
template<int codim, CHECK_CODIM0 >
Codim< codim >::Entity subEntity (int i) const
 
ONLY_CODIM0 bool hasFather () const
 Return true if entity has a father entity which can be accessed using the father() method. More...
 
ONLY_CODIM0 bool isLeaf () const
 Returns true if the entity is contained in the leaf grid. More...
 
ONLY_CODIM0 bool isRegular () const
 Returns true if element is of regular type in red/green type refinement. In bisection or hanging node refinement this is always true. More...
 
ONLY_CODIM0 LocalGeometry geometryInFather () const
 Provides information how this element has been subdivided from its father element. More...
 
ONLY_CODIM0 HierarchicIterator hbegin (int maxLevel) const
 Inter-level access to elements that resulted from (recursive) subdivision of this element. More...
 
ONLY_CODIM0 HierarchicIterator hend (int maxLevel) const
 Returns iterator to one past the last son element. More...
 
ONLY_CODIM0 bool isNew () const
 Returns true, if the entity has been created during the last call to adapt() More...
 
ONLY_CODIM0 bool mightVanish () const
 Returns true, if entity might disappear during the next call to adapt(). If the method returns false, the entity is guaranteed to still be present after adaptation. More...
 
ONLY_CODIM0 bool hasBoundaryIntersections () const
 Returns true, if entity has intersections with boundary. More...
 

Detailed Description

template<class GridImp, class IteratorImp>
class Dune::EntityPointer< GridImp, IteratorImp >

Wrapper class for pointers to entities.

Template parameters are:

Engine Concept

The EntityPointer class template wraps an object of type IteratorImp and forwards all member function calls to corresponding members of this class. In that sense EntityPointer defines the interface and IteratorImp supplies the implementation.

Relation of EntityPointer and Iterators

The EntityPointer can be used like a static iterator. It points to a Dune::Entity and can be dereferenced, compared and it knows the Entity's level.

You should be able to initialize and interpret every Dune::EntityIterator as a Dune::EntityPointer. Therefore we need an inheritance hierarchy of the Iterator wrappers:

class Dune::EntityPointer< Grid, IteratorImp >;
class Dune::EntityIterator< codim, Grid, IteratorImp >
: public Dune::EntityPointer< Grid, IteratorImp >;

This hierarchy must be mimicked in the implementation (e.g. SGrid):

class SEntityPointer<...>;
class SLevelIterator<...> :
public SEntityPointer <...>;
class SHierarchicIterator<...> :
public SEntityPointer <...>;
...

Please note that dereference(...), equals(...) and level() are only implemented in SEntityPointer – SLevelIterator inherits these methods. And it is not possible to specialize these, because EntityPointer always uses the base class.

This leads to a hierarchy where Dune::LevelIterator<..., SLevelIterator> inherits Dune::EntityPointer<..., SLevelIterator> and Dune::HierarchicIterator<..., SHierarchicIterator> inherits Dune::EntityPointer<..., SHierarchicIterator>. And virtually all Dune::EntityPointer<..., SXxxIterator> are descendents of Dune::EntityPointer<..., SEntityPointer>.

Now you can compare Dune::LevelIterator with Dune::EntityPointer and Dune::LeafIterator with Dune::HierarchicIterator. And you can assign Dune::EntityPointer from any Dune::XxxIterator class.

The compiler takes care that you only assign/compare Iterators from the same Grid.

The downside (or advantage) of this inheritance is that you cannot use different comparison operators and different dereference operators for the different Iterators in one Grid. On the first sight it is a downside because one might consider it a good idea to have special treatment for different iterators. On the other hand it's very confusing for the user if different Iterators show different behavior in the same situation. So now they are forced to show the same behavior.

Deprecated:
The EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. It is not needed anymore because starting with dune-grid-2.4, you can now simply copy and store entities directly. If you need to store many entities for an extended time, use EntitySeed instead. Please note that due to the effort required by this change, those grids that are deprecated in dune-grid-2.4 will not have copyable entities, so if you are forced to use one of those grids, you will have to continue using EntityPointer as well.

Member Typedef Documentation

§ Entity

template<class GridImp, class IteratorImp>
typedef IteratorImp::Entity Dune::EntityPointer< GridImp, IteratorImp >::Entity

The Entity that this EntityPointer can point to.

§ EntitySeed

template<class GridImp, class IteratorImp>
typedef GridImp::template Codim<codimension>::EntitySeed Dune::EntityPointer< GridImp, IteratorImp >::EntitySeed

The corresponding entity seed (for storage of entities)

§ Geometry

template<class GridImp, class IteratorImp>
typedef GridImp::template Codim<codimension>::Geometry Dune::EntityPointer< GridImp, IteratorImp >::Geometry

The geometry type of this entity.

§ HierarchicIterator

template<class GridImp, class IteratorImp>
typedef GridImp::HierarchicIterator Dune::EntityPointer< GridImp, IteratorImp >::HierarchicIterator

The codim==0 EntityPointer type.

The HierarchicIterator type

§ Implementation

template<class GridImp, class IteratorImp>
typedef IteratorImp Dune::EntityPointer< GridImp, IteratorImp >::Implementation
protected

§ LocalGeometry

template<class GridImp, class IteratorImp>
typedef GridImp::template Codim<codimension>::LocalGeometry Dune::EntityPointer< GridImp, IteratorImp >::LocalGeometry

The geometry type of this entity when the geometry is expressed embedded in the father element.

This differs from Geometry in particular when dim != dimworld, but even when dim == dimworld the implementation may choose to use a different type here.

§ Reference

template<class GridImp, class IteratorImp>
typedef std::conditional< std::is_lvalue_reference< decltype(realIterator.dereference()) >::value, const Entity&, Entity >::type Dune::EntityPointer< GridImp, IteratorImp >::Reference

Tpy of the reference used when derefencing the Ptr.

Member Enumeration Documentation

§ anonymous enum

template<class GridImp, class IteratorImp>
anonymous enum

codimension of entity pointer

Enumerator
codimension 

§ anonymous enum

template<class GridImp, class IteratorImp>
anonymous enum
Enumerator
dimension 

Know the grid's dimension.

§ anonymous enum

template<class GridImp, class IteratorImp>
anonymous enum
Enumerator
mydimension 

Know dimension of the entity.

Constructor & Destructor Documentation

§ EntityPointer() [1/5]

template<class GridImp, class IteratorImp>
template<class ItImp >
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const EntityPointer< GridImp, ItImp > &  ep)
inlineexplicit

Templatized copy constructor from arbitrary IteratorImp. This enables that an EntityPointer can be copy-constructed from LevelIterator, LeafIterator and HierarchicIterator (because these are derived from EntityPointer<...> with their corresponding implementation.

§ EntityPointer() [2/5]

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( )
inline

Default constructor of an empty (undefined) EntityPointer.

§ EntityPointer() [3/5]

template<class GridImp, class IteratorImp>
DUNE_ENTITYPOINTER_DEPRECATED_MSG Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const Entity entity)
inline

Templatized constructor from type of entity that this entity pointer points to. This constructor can be used to create an entity pointer from an entity in order to store an entity. The implementation of EntityPointer has to have a constructor taking a Dune::Entity.

§ EntityPointer() [4/5]

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const typename Entity::Implementation entityImp)
inline

Constructor from type of entity implementation that this entity pointer points to. This constructor is only used in the EntityDefaultImplementation to implement the method seed() by default when the type of EntitySeed and EntityPointer coniside.

§ EntityPointer() [5/5]

template<class GridImp, class IteratorImp>
Dune::EntityPointer< GridImp, IteratorImp >::EntityPointer ( const IteratorImp &  i)
inline

Copy Constructor from an Iterator implementation.

You can supply LeafIterator, LevelIterator, HierarchicIterator or EntityPointer.

Member Function Documentation

§ equals()

template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::equals ( const EntityPointer< GridImp, ItImp > &  rhs) const
inline

Forward equality check to realIterator.

§ geometry()

template<class GridImp, class IteratorImp>
Geometry Dune::EntityPointer< GridImp, IteratorImp >::geometry ( ) const
inline

obtain geometric realization of the entity

Each entity provides an object of type Dune::Geometry< dimension-codimension, dimensionworld, ... > that represents the map from a reference element to world coordinates.

Note
Previously, the geometry was encapsulated in the entity object and a const reference was returned.
The returned geometry object is guaranteed to remain valid until the grid is modified (or deleted).

§ geometryInFather()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 LocalGeometry Dune::EntityPointer< GridImp, IteratorImp >::geometryInFather ( ) const
inline

Provides information how this element has been subdivided from its father element.

The returned LocalGeometry is a model of Dune::Geometry<dimension,dimension,...>, mapping the reference element of the given entity to the reference element of its father.

This information is sufficient to interpolate all degrees of freedom in the conforming case. Nonconforming may require access to neighbors of the father and calculations with local coordinates. The on-the-fly case is somewhat inefficient since degrees of freedom may be visited several times. If we store interpolation matrices, this is tolerable. We assume that on-the-fly implementation of interpolation is only done for simple discretizations.

Note
For ghost entities, this method is not guaranteed to be implemented.
Previously, the geometry was encapsulated in the entity object and a const reference was returned.
The returned geometry object is guaranteed to remain valid until the grid is modified (or deleted).

§ hasBoundaryIntersections()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::hasBoundaryIntersections ( ) const
inline

Returns true, if entity has intersections with boundary.

§ hasFather()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::hasFather ( ) const
inline

Return true if entity has a father entity which can be accessed using the father() method.

§ hbegin()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 HierarchicIterator Dune::EntityPointer< GridImp, IteratorImp >::hbegin ( int  maxLevel) const
inline

Inter-level access to elements that resulted from (recursive) subdivision of this element.

Parameters
[in]maxlevelIterator does not stop at elements with level greater than maxlevel.
Returns
Iterator to the first son (level is not greater than maxlevel)
Note
If the partitionType of the Entity is GhostEntity, it is not guaranteed that this method is working or implemented in general. For some grids it might be available, though.

§ hend()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 HierarchicIterator Dune::EntityPointer< GridImp, IteratorImp >::hend ( int  maxLevel) const
inline

Returns iterator to one past the last son element.

Note
If the partitionType of the Entity is GhostEntity, it is not guaranteed that this method is working or implemented in general. For some grids it might be available, though.

§ impl() [1/2]

template<class GridImp, class IteratorImp>
Implementation& Dune::EntityPointer< GridImp, IteratorImp >::impl ( )
inlineprotected

return reference to the real implementation

§ impl() [2/2]

template<class GridImp, class IteratorImp>
const Implementation& Dune::EntityPointer< GridImp, IteratorImp >::impl ( ) const
inlineprotected

return reference to the real implementation

§ isLeaf()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::isLeaf ( ) const
inline

Returns true if the entity is contained in the leaf grid.

§ isNew()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::isNew ( ) const
inline

Returns true, if the entity has been created during the last call to adapt()

§ isRegular()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::isRegular ( ) const
inline

Returns true if element is of regular type in red/green type refinement. In bisection or hanging node refinement this is always true.

§ level()

template<class GridImp, class IteratorImp>
int Dune::EntityPointer< GridImp, IteratorImp >::level ( ) const
inline

Ask for level of entity.

This method is redundant and is only there for efficiency reasons. It allows an implementation to return the level without actually constructing the entity.

Deprecated:
Will be removed after the release of dune-grid-2.4. Use the method level() from the dereferenced Entity instead.

§ mightVanish()

template<class GridImp, class IteratorImp>
ONLY_CODIM0 bool Dune::EntityPointer< GridImp, IteratorImp >::mightVanish ( ) const
inline

Returns true, if entity might disappear during the next call to adapt(). If the method returns false, the entity is guaranteed to still be present after adaptation.

§ operator!=() [1/2]

template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::operator!= ( const EntityPointer< GridImp, ItImp > &  rhs) const
inline

Checks for inequality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer.

§ operator!=() [2/2]

template<class GridImp, class IteratorImp>
DUNE_ENTITYPOINTER_DEPRECATED_MSG bool Dune::EntityPointer< GridImp, IteratorImp >::operator!= ( const Entity rhs) const
inline

Compares an EntityPointer with an Entity for inequality.

Deprecated:
This method only exists for backwards compatibility during the 2.4 release cycle and will be removed after dune-grid-2.4 is released.

§ operator*()

template<class GridImp, class IteratorImp>
Entity Dune::EntityPointer< GridImp, IteratorImp >::operator* ( ) const

Dereferencing operator.

§ operator->()

template<class GridImp, class IteratorImp>
const Entity* Dune::EntityPointer< GridImp, IteratorImp >::operator-> ( ) const

Pointer operator.

§ operator=()

template<class GridImp, class IteratorImp>
template<class ItImp >
DUNE_ENTITYPOINTER_DEPRECATED_MSG EntityPointer& Dune::EntityPointer< GridImp, IteratorImp >::operator= ( const EntityPointer< GridImp, ItImp > &  ep)
inline

§ operator==() [1/2]

template<class GridImp, class IteratorImp>
template<class ItImp >
bool Dune::EntityPointer< GridImp, IteratorImp >::operator== ( const EntityPointer< GridImp, ItImp > &  rhs) const
inline

Checks for equality. Only works for EntityPointers and iterators on the same grid. Due to the conversion operators one can compare all kinds of iterators and EntityPointer.

§ operator==() [2/2]

template<class GridImp, class IteratorImp>
DUNE_ENTITYPOINTER_DEPRECATED_MSG bool Dune::EntityPointer< GridImp, IteratorImp >::operator== ( const Entity rhs) const
inline

Compares an EntityPointer with an Entity for equality.

Deprecated:
This method only exists for backwards compatibility during the 2.4 release cycle and will be removed after dune-grid-2.4 is released.

§ partitionType()

template<class GridImp, class IteratorImp>
PartitionType Dune::EntityPointer< GridImp, IteratorImp >::partitionType ( ) const
inline

Partition type of this entity.

§ seed()

template<class GridImp, class IteratorImp>
EntitySeed Dune::EntityPointer< GridImp, IteratorImp >::seed ( ) const
inline

Return the entity seed which contains sufficient information to generate the entity again and uses as little memory as possible.

§ subEntity()

template<class GridImp, class IteratorImp>
template<int codim, CHECK_CODIM0 >
Codim<codim>::Entity Dune::EntityPointer< GridImp, IteratorImp >::subEntity ( int  i) const
inline

§ type()

template<class GridImp, class IteratorImp>
GeometryType Dune::EntityPointer< GridImp, IteratorImp >::type ( ) const
inline

Return the name of the reference element. The type can be used to access the Dune::ReferenceElement.

Member Data Documentation

§ realIterator

template<class GridImp, class IteratorImp>
Implementation Dune::EntityPointer< GridImp, IteratorImp >::realIterator
protected

The documentation for this class was generated from the following file: