Peano 4
Loading...
Searching...
No Matches
toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T > Struct Template Reference

Memory pool offering continuous global memory for a particle species. More...

#include <VertexWiseContinuousMemoryPool.h>

Collaboration diagram for toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >:

Public Types

typedef std::list< T * > Container
 

Public Member Functions

 VertexWiseContinuousMemoryPool ()
 
void scatter ()
 If the data are scattered already, nothing is to be done.
 
Container::iterator scatterAndUpdateIterator (const typename Container::iterator &p)
 Scatter the data if not scattered yet and return the updated iterator.
 
void gather ()
 Gather the particle.
 
bool isGathered () const
 Is the vertex data gathered.
 
void replace (typename Container::iterator p, T *newCopy)
 Replace particle.
 
void clearAndReset ()
 Clears the underlying list of pointers and resets _gatheredDataPointer to nullptr.
 

Static Public Member Functions

static bool requestCompleteScatter ()
 Recommend complete scatter.
 

Data Fields

Container container
 

Private Attributes

T * _gatheredDataPointer
 Is nullptr as long as data is not gathered.
 

Static Private Attributes

static tarch::logging::Log _log
 

Detailed Description

template<class T>
struct toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >

Memory pool offering continuous global memory for a particle species.

Consult the generic description of memory pools before you continue to read this documentation. This class is used by every "vertex" object, i.e. each vertex holds one instance of the pool object. Basically, the field container is used to point to all the particles scattered over the memory after we've created the particles. However, whenever we call gather(), we take all of these particles from the heap, put them into one continuous container and then make the pointers within container point to those guys.

Definition at line 30 of file VertexWiseContinuousMemoryPool.h.

Member Typedef Documentation

◆ Container

template<class T >
typedef std::list<T*> toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::Container

Definition at line 32 of file VertexWiseContinuousMemoryPool.h.

Constructor & Destructor Documentation

◆ VertexWiseContinuousMemoryPool()

template<class T >
toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::VertexWiseContinuousMemoryPool ( )

Definition at line 10 of file VertexWiseContinuousMemoryPool.cpph.

Member Function Documentation

◆ clearAndReset()

template<class T >
void toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::clearAndReset ( )

Clears the underlying list of pointers and resets _gatheredDataPointer to nullptr.

The routine does not free the memory. This routine is used by shallow clears().

Definition at line 38 of file VertexWiseContinuousMemoryPool.cpph.

◆ gather()

template<class T >
void toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::gather ( )

Gather the particle.

If we invoke this routine on a gathered memory pool, it becomes nop. Otherwise, the routine's implementation is rather straightforward:

  • Allocate one big chunk of memory
  • Run over the list of pointers. This run-through has to be done with a reference, as we will change the pointers on our way. So we use auto& as type.
  • Copy the current iterator element over into the big chunk of memory and increment the counter in there.
  • Delete the original piece of data on the global heap.
  • Make the list pointer point to the new fragment within the memory.

Please note that it makes no sense to gather an empty set, so we explicitly take that into account as well.

Definition at line 76 of file VertexWiseContinuousMemoryPool.cpph.

References assertion, tarch::Heap, and logDebug.

◆ isGathered()

template<class T >
bool toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::isGathered ( ) const

Is the vertex data gathered.

This routine returns false if the underlying container is empty.

Definition at line 98 of file VertexWiseContinuousMemoryPool.cpph.

◆ replace()

template<class T >
void toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::replace ( typename Container::iterator p,
T * newCopy )

Replace particle.

Takes the particle identified via p and copies the content of newCopy over.

If our data is gathered, we copy stuff over. After that, newCopy is deleted. If our data is scattered, we can just delete the original one and push back the new copy.

Definition at line 104 of file VertexWiseContinuousMemoryPool.cpph.

References assertion.

◆ requestCompleteScatter()

template<class T >
bool toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::requestCompleteScatter ( )
static

Recommend complete scatter.

A memory pool can recommend a complete scatter. The memory pool should do this if the memory is managed becomes too scattered, or any pre-allocated memory region is too small. We always return false in the present implementation.

Definition at line 16 of file VertexWiseContinuousMemoryPool.cpph.

◆ scatter()

template<class T >
void toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::scatter ( )

If the data are scattered already, nothing is to be done.

If not, take all the particles from the continuous memory chunk and throw them onto the heap. After that, free the en bloc allocation.

Definition at line 22 of file VertexWiseContinuousMemoryPool.cpph.

References assertion, tarch::freeMemory(), tarch::Heap, and logDebug.

Here is the call graph for this function:

◆ scatterAndUpdateIterator()

template<class T >
toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::Container::iterator toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::scatterAndUpdateIterator ( const typename Container::iterator & p)

Scatter the data if not scattered yet and return the updated iterator.

Routine is used by particleCanNotBeLiftedLocally(), grabParticle(), and deleteParticle(). Basically, we run through the particles. If we have to remove one from this list, we tell the vertex to scatter. After that, we don't want to run through the whole list again, so we expect the routine to give us an updated iterator of that particle that has to be lifted.

Definition at line 46 of file VertexWiseContinuousMemoryPool.cpph.

References assertion, tarch::freeMemory(), tarch::Heap, and logDebug.

Here is the call graph for this function:

Field Documentation

◆ _gatheredDataPointer

template<class T >
T* toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::_gatheredDataPointer
private

Is nullptr as long as data is not gathered.

Definition at line 119 of file VertexWiseContinuousMemoryPool.h.

◆ _log

◆ container


The documentation for this struct was generated from the following files: