Dune Core Modules (2.9.0)

Dune::PersistentContainerInterface< G, T > Class Template Reference

Persistent storage of data on all entities of a grid. More...

#include <dune/grid/utility/persistentcontainerinterface.hh>

Public Member Functions

 PersistentContainerInterface (Grid &grid, int codim, const Value &value=Value())
 constuctor More...
 
 PersistentContainerInterface (const This &other)
 copy constructor
 
const Thisoperator= (const This &other)
 assignment operator
 
template<class Entity >
const Value & operator[] (const Entity &entity) const
 access the data associated with an entity More...
 
template<class Entity >
Value & operator[] (const Entity &entity)
 access the data associated with an entity More...
 
template<class Entity >
const Value & operator() (const Entity &entity, int subEntity) const
 access the data associated with a subentity More...
 
template<class Entity >
Value & operator() (const Entity &entity, int subEntity)
 access the data associated with a subentity More...
 
Size size () const
 number of entries in the container More...
 
void resize (const Value &value=Value())
 reserve memory for all entities in the grid More...
 
void shrinkToFit ()
 remove unnecessary entries from container More...
 
void fill (const Value &value)
 set all accessible entries to a given value More...
 
void swap (This &other)
 exchange the content of the container with another one More...
 
ConstIterator begin () const
 returns an iterator pointing to the first element of the container More...
 
Iterator begin ()
 returns an iterator pointing to the first element of the container More...
 
ConstIterator end () const
 returns an iterator pointing to the last element of the container More...
 
Iterator end ()
 returns an iterator pointing to the last element of the container More...
 
int codimension () const
 return the codimension, the container attaches data to
 

Detailed Description

template<class G, class T>
class Dune::PersistentContainerInterface< G, T >

Persistent storage of data on all entities of a grid.

This container allows to store data which is to remain persistent even during adaptation cycles. It provides storage for all entities in the hierarchy of a given codimension (provided dynamically during construction) and behaves much like an STL container.

The container stores one entry for each entity in the hierarchical grid. However, it may also store some additional entries, which are not (or no longer) attached to an entity.

After grid modification the method resize must be called to ensure entries for each entity in the modified grid. Accessing newly created entities before calling resize results in undefined behavior (e.g., a segmentation fault). To reduce the amount of overallocated entries, the method shrinkToFit may be called. It is explicitly possible that the grid adapts any persistent containers directly during the adaptation process.

The containers are also be persistent over backup / restore of the grid. After 'shrinkToFit', the entries in the container (and their order) must match those of a newly created container, even after a backup and restore of the grid.

There is a default implementation based on std::map but a grid implementation may provide a specialized implementation. Grids with a hashable id type can use std::unordered_map to store the data by simply deriving their PersistentContainer from Dune::PersistentContainerMap. For grids providing an id set suitable addressing vector-like storages, i.e., the id is an integral type and a method size() is provided, Dune::PersistentContainerVector can be used.

Template Parameters
GGrid type
TContainer's value type

Constructor & Destructor Documentation

◆ PersistentContainerInterface()

template<class G , class T >
Dune::PersistentContainerInterface< G, T >::PersistentContainerInterface ( Grid &  grid,
int  codim,
const Value &  value = Value() 
)

constuctor

Parameters
[in]gridreference to the grid to attach data to
[in]codimcodimension to attach data to
[in]valuevalue for initial entries
Note
All implementations must provide at least this constructor.

Member Function Documentation

◆ begin() [1/2]

template<class G , class T >
Iterator Dune::PersistentContainerInterface< G, T >::begin ( )

returns an iterator pointing to the first element of the container

Note
Iterators stop at all entries of the container, even if they are no longer accessible from the grid.

◆ begin() [2/2]

template<class G , class T >
ConstIterator Dune::PersistentContainerInterface< G, T >::begin ( ) const

returns an iterator pointing to the first element of the container

Note
Iterators stop at all entries of the container, even if they are no longer accessible from the grid.

◆ end() [1/2]

template<class G , class T >
Iterator Dune::PersistentContainerInterface< G, T >::end ( )

returns an iterator pointing to the last element of the container

Note
Iterators stop at all entries of the container, even if they are no longer accessible from the grid.

◆ end() [2/2]

template<class G , class T >
ConstIterator Dune::PersistentContainerInterface< G, T >::end ( ) const

returns an iterator pointing to the last element of the container

Note
Iterators stop at all entries of the container, even if they are no longer accessible from the grid.

◆ fill()

template<class G , class T >
void Dune::PersistentContainerInterface< G, T >::fill ( const Value &  value)

set all accessible entries to a given value

Note
It is undefined, whether the inaccessible values are also motified.

◆ operator()() [1/2]

template<class G , class T >
template<class Entity >
Value & Dune::PersistentContainerInterface< G, T >::operator() ( const Entity entity,
int  subEntity 
)

access the data associated with a subentity

Note
The codimension of the entity must be less or equal to the codimension of the container.

◆ operator()() [2/2]

template<class G , class T >
template<class Entity >
const Value & Dune::PersistentContainerInterface< G, T >::operator() ( const Entity entity,
int  subEntity 
) const

access the data associated with a subentity

Note
The codimension of the entity must be less or equal to the codimension of the container.

◆ operator[]() [1/2]

template<class G , class T >
template<class Entity >
Value & Dune::PersistentContainerInterface< G, T >::operator[] ( const Entity entity)

access the data associated with an entity

Note
The entity must be of the same codimension as the container

◆ operator[]() [2/2]

template<class G , class T >
template<class Entity >
const Value & Dune::PersistentContainerInterface< G, T >::operator[] ( const Entity entity) const

access the data associated with an entity

Note
The entity must be of the same codimension as the container

◆ resize()

template<class G , class T >
void Dune::PersistentContainerInterface< G, T >::resize ( const Value &  value = Value())

reserve memory for all entities in the grid

This method will enlarge the container such that there is an entry for each entity.

After a grid modification, this method must be called before accessing any data associated to newly created entities.

Note
The container might still hold entries for entities that no longer exist in the grid. While those entries ca no longer be accessed through an entity, iterators will still stop at such entries.

◆ shrinkToFit()

template<class G , class T >
void Dune::PersistentContainerInterface< G, T >::shrinkToFit ( )

remove unnecessary entries from container

This method will remove entries from the container that can no longer be accessed from the grid.

The entries in the container (and their order) must match those of a newly created container. This property must be persistent over backup / restore of the grid.

Note
This method is merely a hint to the container. According to the container's internal addressing rules, some inaccessible entries might remain in the container.

◆ size()

template<class G , class T >
Size Dune::PersistentContainerInterface< G, T >::size ( ) const

number of entries in the container

Note
The number of entries in the container may be large than the number of entities in the grid.

◆ swap()

template<class G , class T >
void Dune::PersistentContainerInterface< G, T >::swap ( This other)

exchange the content of the container with another one

Note
std::swap is overloaded to refor to this method

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 (Dec 20, 23:31, 2024)