if (property_pool != nullptr &&
properties != PropertyPool<dim, spacedim>::invalid_handle)
{
- new_handle = new_property_pool.allocate_properties_array();
+ new_handle = new_property_pool.register_particle();
ArrayView<double> old_properties = this->get_properties();
ArrayView<double> new_properties =
// release those.
if (property_pool != nullptr &&
properties != PropertyPool<dim, spacedim>::invalid_handle)
- property_pool->deallocate_properties_array(properties);
+ property_pool->deregister_particle(properties);
// Then set the pointer to the property pool we want to use. Also set the
clear();
/**
- * Return a new handle that allows accessing the reserved particle
- * properties. If the number of properties is zero this will return an
- * invalid handle. Handles can be copied, but after deallocating one
- * of the copied handles using any of the other copies will cause
- * undefined behavior.
+ * Return a new handle that allows a particle to store information such as
+ * properties and locations. This also allocated memory in this PropertyPool
+ * variable.
*/
Handle
- allocate_properties_array();
+ register_particle();
/**
- * Mark the properties corresponding to the handle @p handle as
- * deleted and invalidate the @p handle. Calling this function
- * more than once for the same handle (e.g. by calling it again
- * with a copy of the previously invalidated handle) causes
- * undefined behavior.
+ * Return a handle obtained by register_particle() and mark the memory
+ * allocated for storing the particle's data as free for re-use.
*/
void
- deallocate_properties_array(Handle &handle);
+ deregister_particle(Handle &handle);
/**
* Return an ArrayView to the properties that correspond to the given
{
if (particle.has_properties())
{
- properties = property_pool->allocate_properties_array();
+ properties = property_pool->register_particle();
const ArrayView<double> my_properties =
property_pool->get_properties(properties);
const ArrayView<const double> their_properties =
property_pool = new_property_pool;
if (property_pool != nullptr)
- properties = property_pool->allocate_properties_array();
+ properties = property_pool->register_particle();
else
properties = PropertyPool<dim, spacedim>::invalid_handle;
if (particle.has_properties())
{
- properties = property_pool->allocate_properties_array();
+ properties = property_pool->register_particle();
const ArrayView<const double> their_properties =
particle.get_properties();
const ArrayView<double> my_properties =
{
if (property_pool != nullptr &&
properties != PropertyPool<dim, spacedim>::invalid_handle)
- property_pool->deallocate_properties_array(properties);
+ property_pool->deregister_particle(properties);
}
template <int dim, int spacedim>
{
if (property_pool != nullptr &&
properties != PropertyPool<dim, spacedim>::invalid_handle)
- property_pool->deallocate_properties_array(properties);
+ property_pool->deregister_particle(properties);
}
// If we haven't allocated memory yet, do so now
if (properties == PropertyPool<dim, spacedim>::invalid_handle)
- properties = property_pool->allocate_properties_array();
+ properties = property_pool->register_particle();
const ArrayView<double> property_values =
property_pool->get_properties(properties);
// If this particle has no properties yet, allocate and initialize them.
if (properties == PropertyPool<dim, spacedim>::invalid_handle)
{
- properties = property_pool->allocate_properties_array();
+ properties = property_pool->register_particle();
ArrayView<double> my_properties =
property_pool->get_properties(properties);
template <int dim, int spacedim>
typename PropertyPool<dim, spacedim>::Handle
- PropertyPool<dim, spacedim>::allocate_properties_array()
+ PropertyPool<dim, spacedim>::register_particle()
{
Handle handle = invalid_handle;
if (n_properties > 0)
template <int dim, int spacedim>
void
- PropertyPool<dim, spacedim>::deallocate_properties_array(Handle &handle)
+ PropertyPool<dim, spacedim>::deregister_particle(Handle &handle)
{
Assert(
handle != invalid_handle,
Particles::PropertyPool<dim, spacedim> pool(1);
typename Particles::PropertyPool<dim, spacedim>::Handle handle =
- pool.allocate_properties_array();
+ pool.register_particle();
pool.get_properties(handle)[0] = 2.5;
deallog << "Pool properties: " << pool.get_properties(handle)[0]
<< std::endl;
- pool.deallocate_properties_array(handle);
+ pool.deregister_particle(handle);
}
deallog << "OK" << std::endl;
Particles::PropertyPool<dim, spacedim> pool(n_properties);
typename Particles::PropertyPool<dim, spacedim>::Handle handle =
- pool.allocate_properties_array();
+ pool.register_particle();
pool.get_properties(handle)[0] = 1.2;
pool.get_properties(handle)[1] = 2.5;
deallog << std::endl;
- pool.deallocate_properties_array(handle);
+ pool.deregister_particle(handle);
}
deallog << "OK" << std::endl;