dune-grid 2.9.0
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Dune::PersistentContainer< G, T > Class Template Reference

A class for storing data during an adaptation cycle. More...

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

Inheritance diagram for Dune::PersistentContainer< G, T >:
Inheritance graph

Public Types

typedef Base::Grid Grid
 
typedef Base::Value Value
 
typedef Map::size_type Size
 
typedef IteratorWrapper< const Value, typename Map::const_iterator > ConstIterator
 
typedef IteratorWrapper< Value, typename Map::iterator > Iterator
 

Public Member Functions

 PersistentContainer (const Grid &grid, int codim, const Value &value=Value())
 
const Valueoperator[] (const Entity &entity) const
 
Valueoperator[] (const Entity &entity)
 
const Valueoperator() (const Entity &entity, int subEntity) const
 
Valueoperator() (const Entity &entity, int subEntity)
 
Size size () const
 
void resize (const Value &value=Value())
 
void shrinkToFit ()
 
void fill (const Value &value)
 
void swap (This &other)
 
ConstIterator begin () const
 
Iterator begin ()
 
ConstIterator end () const
 
Iterator end ()
 
int codimension () const
 

Protected Member Functions

void resize (const Value &value)
 
const Gridgrid () const
 
void migrateLevel (int level, const Value &value, std::map< G::LocalIdSet::IdType, T > &data, std::integral_constant< bool, true >)
 
void migrateLevel (int level, const Value &value, std::map< G::LocalIdSet::IdType, T > &data, std::integral_constant< bool, false >)
 
const G::LocalIdSet & idSet () const
 

Static Protected Member Functions

static void migrateEntry (const typename IdSet::IdType &id, const Value &value, std::map< G::LocalIdSet::IdType, T > &oldData, std::map< G::LocalIdSet::IdType, T > &newData)
 

Protected Attributes

const Gridgrid_
 
int codim_
 
const G::LocalIdSet * idSet_
 
std::map< G::LocalIdSet::IdType, T > data_
 

Detailed Description

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

A class for storing data during an adaptation cycle.

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

Member Typedef Documentation

◆ ConstIterator

typedef IteratorWrapper< const Value, typename Map::const_iterator > Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::ConstIterator
inherited

◆ Grid

template<class G , class T >
typedef Base::Grid Dune::PersistentContainer< G, T >::Grid

◆ Iterator

typedef IteratorWrapper< Value, typename Map::iterator > Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::Iterator
inherited

◆ Size

typedef Map::size_type Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::Size
inherited

◆ Value

template<class G , class T >
typedef Base::Value Dune::PersistentContainer< G, T >::Value

Constructor & Destructor Documentation

◆ PersistentContainer()

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

Member Function Documentation

◆ begin() [1/2]

PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::Iterator Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::begin
inlineinherited

◆ begin() [2/2]

PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::ConstIterator Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::begin
inlineinherited

◆ codimension()

int Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::codimension ( ) const
inlineinherited

◆ end() [1/2]

PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::Iterator Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::end
inlineinherited

◆ end() [2/2]

PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::ConstIterator Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::end
inlineinherited

◆ fill()

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::fill ( const Value value)
inlineinherited

◆ grid()

const Grid & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::grid ( ) const
inlineprotectedinherited

◆ idSet()

const G::LocalIdSet & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::idSet ( ) const
inlineprotectedinherited

◆ migrateEntry()

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::migrateEntry ( const typename IdSet::IdType id,
const Value value,
std::map< G::LocalIdSet::IdType, T > &  oldData,
std::map< G::LocalIdSet::IdType, T > &  newData 
)
inlinestaticprotectedinherited

◆ migrateLevel() [1/2]

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::migrateLevel ( int  level,
const Value value,
std::map< G::LocalIdSet::IdType, T > &  data,
std::integral_constant< bool, false >   
)
inlineprotectedinherited

◆ migrateLevel() [2/2]

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::migrateLevel ( int  level,
const Value value,
std::map< G::LocalIdSet::IdType, T > &  data,
std::integral_constant< bool, true >   
)
inlineprotectedinherited

◆ operator()() [1/2]

Value & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::operator() ( const Entity entity,
int  subEntity 
)
inlineinherited

◆ operator()() [2/2]

const Value & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::operator() ( const Entity entity,
int  subEntity 
) const
inlineinherited

◆ operator[]() [1/2]

Value & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::operator[] ( const Entity entity)
inlineinherited

◆ operator[]() [2/2]

const Value & Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::operator[] ( const Entity entity) const
inlineinherited

◆ resize() [1/2]

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::resize ( const Value value)
protectedinherited

◆ resize() [2/2]

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::resize ( const Value value = Value())
inlineinherited

◆ shrinkToFit()

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::shrinkToFit ( )
inlineinherited

◆ size()

Size Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::size ( ) const
inlineinherited

◆ swap()

void Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::swap ( This other)
inlineinherited

Member Data Documentation

◆ codim_

int Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::codim_
protectedinherited

◆ data_

std::map< G::LocalIdSet::IdType, T > Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::data_
protectedinherited

◆ grid_

const Grid* Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::grid_
protectedinherited

◆ idSet_

const G::LocalIdSet * Dune::PersistentContainerMap< G, G::LocalIdSet , std::map< G::LocalIdSet::IdType, T > >::idSet_
protectedinherited

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