![]() |
Peano
|
Memory pool offering continuous global memory for a particle species. More...
#include <VertexWiseContinuousMemoryPool.h>
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 |
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.
typedef std::list<T*> toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::Container |
Definition at line 32 of file VertexWiseContinuousMemoryPool.h.
toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::VertexWiseContinuousMemoryPool | ( | ) |
Definition at line 10 of file VertexWiseContinuousMemoryPool.cpph.
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.
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:
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.
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.
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.
|
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.
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.
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.
|
private |
Is nullptr as long as data is not gathered.
Definition at line 119 of file VertexWiseContinuousMemoryPool.h.
|
staticprivate |
Definition at line 114 of file VertexWiseContinuousMemoryPool.h.
Container toolbox::particles::memorypool::VertexWiseContinuousMemoryPool< T >::container |
Definition at line 34 of file VertexWiseContinuousMemoryPool.h.