dune-grid  2.4.1
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Dune::EntityPointer< GridImp, IteratorImp > Singleton 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
EntityPointer
operator= (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>
singleton 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 SEntityPointerSLevelIterator 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 virtualy 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

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

The Entity that this EntityPointer can point to.

template<class GridImp, class IteratorImp>
typedef IteratorImp Dune::EntityPointer< GridImp, IteratorImp >::Implementation
protected
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.

Constructor & Destructor Documentation

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.

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

Default constructor of an empty (undefined) EntityPointer.

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.

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.

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

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

return reference to the real implementation

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

return reference to the real implementation

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.
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.

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.
template<class GridImp, class IteratorImp>
Entity Dune::EntityPointer< GridImp, IteratorImp >::operator* ( ) const

Dereferencing operator.

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

Pointer 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
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.

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.

Member Data Documentation

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

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