Reference documentation for deal.II version 9.0.0
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Particles::PropertyPool Class Reference

#include <deal.II/particles/property_pool.h>

Public Types

typedef double * Handle
 

Public Member Functions

 PropertyPool (const unsigned int n_properties_per_slot)
 
Handle allocate_properties_array ()
 
void deallocate_properties_array (const Handle handle)
 
ArrayView< double > get_properties (const Handle handle)
 
void reserve (const std::size_t size)
 
unsigned int n_properties_per_slot () const
 

Static Public Attributes

static const Handle invalid_handle = nullptr
 

Private Attributes

const unsigned int n_properties
 

Detailed Description

This class manages a memory space in which particles store their properties. Because this is dynamic memory and often every particle needs the same amount, it is more efficient to let this be handled by a central manager that does not need to allocate/deallocate memory every time a particle is constructed/destroyed. The current implementation uses simple new/delete allocation for every block. Additionally, the current implementation assumes the same number of properties per particle, but of course the PropertyType could contain a pointer to dynamically allocated memory with varying sizes per particle (this memory would not be managed by this class). Because PropertyPool only returns handles it could be enhanced internally (e.g. to allow for varying number of properties per handle) without affecting its interface.

Definition at line 41 of file property_pool.h.

Member Typedef Documentation

◆ Handle

Typedef for the handle that is returned to the particles, and that uniquely identifies the slot of memory that is reserved for this particle.

Definition at line 49 of file property_pool.h.

Constructor & Destructor Documentation

◆ PropertyPool()

Particles::PropertyPool::PropertyPool ( const unsigned int  n_properties_per_slot)

Constructor. Stores the number of properties per reserved slot.

Definition at line 26 of file property_pool.cc.

Member Function Documentation

◆ allocate_properties_array()

PropertyPool::Handle Particles::PropertyPool::allocate_properties_array ( )

Return a new handle that allows accessing the reserved block of memory. If the number of properties is zero this will return an invalid handle.

Definition at line 34 of file property_pool.cc.

◆ deallocate_properties_array()

void Particles::PropertyPool::deallocate_properties_array ( const Handle  handle)

Mark the properties corresponding to the handle handle as deleted. Calling this function more than once for the same handle causes undefined behavior.

Definition at line 46 of file property_pool.cc.

◆ get_properties()

ArrayView< double > Particles::PropertyPool::get_properties ( const Handle  handle)

Return an ArrayView to the properties that correspond to the given handle handle.

Definition at line 54 of file property_pool.cc.

◆ reserve()

void Particles::PropertyPool::reserve ( const std::size_t  size)

Reserve the dynamic memory needed for storing the properties of size particles.

Definition at line 62 of file property_pool.cc.

◆ n_properties_per_slot()

unsigned int Particles::PropertyPool::n_properties_per_slot ( ) const

Return how many properties are stored per slot in the pool.

Definition at line 70 of file property_pool.cc.

Member Data Documentation

◆ invalid_handle

const PropertyPool::Handle Particles::PropertyPool::invalid_handle = nullptr
static

Define a default (invalid) value for handles.

Definition at line 54 of file property_pool.h.

◆ n_properties

const unsigned int Particles::PropertyPool::n_properties
private

The number of properties that are reserved per particle.

Definition at line 96 of file property_pool.h.


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