Dune Core Modules (2.5.0)

Dune::EntityPointer< GridImp, IteratorImp > Class Template Reference

Wrapper class for pointers to entities. More...

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

Classes

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

Public Types

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

Public Member Functions

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.
 
 EntityPointer ()
 Default constructor of an empty (undefined) EntityPointer.
 
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.
 
 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.
 
template<class ItImp >
DUNE_ENTITYPOINTER_DEPRECATED_MSG EntityPointeroperator= (const EntityPointer< GridImp, ItImp > &ep)
 
Dereferencing
Entity operator* () const DUNE_ENTITYPOINTER_DEPRECATED_MSG
 Dereferencing operator.
 
const Entityoperator-> () const DUNE_ENTITYPOINTER_DEPRECATED_MSG
 Pointer operator.
 
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.
 
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.
 
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...
 
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.
 

Protected Member Functions

Implementation & impl ()
 return reference to the real implementation
 
const Implementation & impl () const
 return reference to the real implementation
 

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.
 
typedef GridImp::template Codim< codimension >::EntitySeed EntitySeed
 The corresponding entity seed (for storage of entities)
 
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.
 
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.
 
EntitySeed seed () const
 Return the entity seed which contains sufficient information to generate the entity again and uses as little memory as possible.
 
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.
 
ONLY_CODIM0 bool isLeaf () const
 Returns true if the entity is contained in the leaf grid.
 
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.
 
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()
 
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.
 
ONLY_CODIM0 bool hasBoundaryIntersections () const
 Returns true, if entity has intersections with boundary.
 

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 >;
interface class for an iterator over grid entities
Definition: entityiterator.hh:37
Wrapper class for pointers to entities.
Definition: entitypointer.hh:115
Grid abstract base class.
Definition: grid.hh:373

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

◆ HierarchicIterator

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

The codim==0 EntityPointer type.

The HierarchicIterator type

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

Member Enumeration Documentation

◆ 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()

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

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

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

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

◆ operator!=()

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

The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)