Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
aspect::Particle::PropertyPool Class Reference

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

Private Attributes

const unsigned int n_properties

Detailed Description

This class manages the memory space in which particles store their properties. Because this is dynamic memory and 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.

Definition at line 43 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 51 of file property_pool.h.

Constructor & Destructor Documentation

§ PropertyPool()

aspect::Particle::PropertyPool::PropertyPool ( const unsigned int  n_properties_per_slot)

Constructor. Stores the number of properties per reserved slot.

Member Function Documentation

§ allocate_properties_array()

Handle aspect::Particle::PropertyPool::allocate_properties_array ( )

Returns a new handle that allows accessing the reserved block of memory.

§ deallocate_properties_array()

void aspect::Particle::PropertyPool::deallocate_properties_array ( const Handle  handle)

Mark the properties corresponding to the handle handle as deleted. After calling this function calling get_properties() with the freed handle causes undefined behavior.

§ get_properties()

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

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

§ reserve()

void aspect::Particle::PropertyPool::reserve ( const std::size_t  size)

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

§ n_properties_per_slot()

unsigned int aspect::Particle::PropertyPool::n_properties_per_slot ( ) const

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

Member Data Documentation

§ invalid_handle

const Handle aspect::Particle::PropertyPool::invalid_handle

Define a default (invalid) value for handles.

Definition at line 56 of file property_pool.h.

§ n_properties

const unsigned int aspect::Particle::PropertyPool::n_properties

The number of properties that are reserved per particle.

Definition at line 97 of file property_pool.h.

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