dune-grid 2.9.0
|
Persistent storage of data on all entities of a grid. More...
#include <dune/grid/utility/persistentcontainerinterface.hh>
Public Types | |
typedef G | Grid |
typedef T | Value |
typedef ImplementationDefined | Size |
typedef ImplementationDefined | ConstIterator |
typedef ImplementationDefined | Iterator |
Public Member Functions | |
PersistentContainerInterface (Grid &grid, int codim, const Value &value=Value()) | |
constuctor More... | |
PersistentContainerInterface (const This &other) | |
copy constructor More... | |
const This & | operator= (const This &other) |
assignment operator More... | |
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 More... | |
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.
G | Grid type |
T | Container's value type |
typedef ImplementationDefined Dune::PersistentContainerInterface< G, T >::ConstIterator |
typedef G Dune::PersistentContainerInterface< G, T >::Grid |
typedef ImplementationDefined Dune::PersistentContainerInterface< G, T >::Iterator |
typedef ImplementationDefined Dune::PersistentContainerInterface< G, T >::Size |
typedef T Dune::PersistentContainerInterface< G, T >::Value |
Dune::PersistentContainerInterface< G, T >::PersistentContainerInterface | ( | Grid & | grid, |
int | codim, | ||
const Value & | value = Value() |
||
) |
constuctor
[in] | grid | reference to the grid to attach data to |
[in] | codim | codimension to attach data to |
[in] | value | value for initial entries |
Dune::PersistentContainerInterface< G, T >::PersistentContainerInterface | ( | const This & | other | ) |
copy constructor
Iterator Dune::PersistentContainerInterface< G, T >::begin | ( | ) |
returns an iterator pointing to the first element of the container
ConstIterator Dune::PersistentContainerInterface< G, T >::begin | ( | ) | const |
returns an iterator pointing to the first element of the container
int Dune::PersistentContainerInterface< G, T >::codimension | ( | ) | const |
return the codimension, the container attaches data to
Iterator Dune::PersistentContainerInterface< G, T >::end | ( | ) |
returns an iterator pointing to the last element of the container
ConstIterator Dune::PersistentContainerInterface< G, T >::end | ( | ) | const |
returns an iterator pointing to the last element of the container
void Dune::PersistentContainerInterface< G, T >::fill | ( | const Value & | value | ) |
set all accessible entries to a given value
Value & Dune::PersistentContainerInterface< G, T >::operator() | ( | const Entity & | entity, |
int | subEntity | ||
) |
access the data associated with a subentity
const Value & Dune::PersistentContainerInterface< G, T >::operator() | ( | const Entity & | entity, |
int | subEntity | ||
) | const |
access the data associated with a subentity
const This & Dune::PersistentContainerInterface< G, T >::operator= | ( | const This & | other | ) |
assignment operator
Value & Dune::PersistentContainerInterface< G, T >::operator[] | ( | const Entity & | entity | ) |
access the data associated with an entity
const Value & Dune::PersistentContainerInterface< G, T >::operator[] | ( | const Entity & | entity | ) | const |
access the data associated with an entity
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.
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.
Size Dune::PersistentContainerInterface< G, T >::size | ( | ) | const |
number of entries in the container
void Dune::PersistentContainerInterface< G, T >::swap | ( | This & | other | ) |
exchange the content of the container with another one