From b0f3a781d52119df62bc8bd48740109f4f8b89cd Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 12 Dec 2020 11:22:07 -0700 Subject: [PATCH] Rename some member functions of PropertyPool. --- include/deal.II/particles/particle.h | 4 ++-- include/deal.II/particles/property_pool.h | 19 +++++++------------ source/particles/particle.cc | 14 +++++++------- source/particles/property_pool.cc | 4 ++-- tests/particles/property_pool_01.cc | 4 ++-- tests/particles/property_pool_02.cc | 4 ++-- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/include/deal.II/particles/particle.h b/include/deal.II/particles/particle.h index 3b107b2fc5..fb6b87e571 100644 --- a/include/deal.II/particles/particle.h +++ b/include/deal.II/particles/particle.h @@ -602,7 +602,7 @@ namespace Particles if (property_pool != nullptr && properties != PropertyPool::invalid_handle) { - new_handle = new_property_pool.allocate_properties_array(); + new_handle = new_property_pool.register_particle(); ArrayView old_properties = this->get_properties(); ArrayView new_properties = @@ -616,7 +616,7 @@ namespace Particles // release those. if (property_pool != nullptr && properties != PropertyPool::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 diff --git a/include/deal.II/particles/property_pool.h b/include/deal.II/particles/property_pool.h index f733b65128..1ce02000a2 100644 --- a/include/deal.II/particles/property_pool.h +++ b/include/deal.II/particles/property_pool.h @@ -82,24 +82,19 @@ namespace Particles 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 diff --git a/source/particles/particle.cc b/source/particles/particle.cc index 3a81b08718..db9c53e601 100644 --- a/source/particles/particle.cc +++ b/source/particles/particle.cc @@ -55,7 +55,7 @@ namespace Particles { if (particle.has_properties()) { - properties = property_pool->allocate_properties_array(); + properties = property_pool->register_particle(); const ArrayView my_properties = property_pool->get_properties(properties); const ArrayView their_properties = @@ -87,7 +87,7 @@ namespace Particles property_pool = new_property_pool; if (property_pool != nullptr) - properties = property_pool->allocate_properties_array(); + properties = property_pool->register_particle(); else properties = PropertyPool::invalid_handle; @@ -132,7 +132,7 @@ namespace Particles if (particle.has_properties()) { - properties = property_pool->allocate_properties_array(); + properties = property_pool->register_particle(); const ArrayView their_properties = particle.get_properties(); const ArrayView my_properties = @@ -178,7 +178,7 @@ namespace Particles { if (property_pool != nullptr && properties != PropertyPool::invalid_handle) - property_pool->deallocate_properties_array(properties); + property_pool->deregister_particle(properties); } template @@ -187,7 +187,7 @@ namespace Particles { if (property_pool != nullptr && properties != PropertyPool::invalid_handle) - property_pool->deallocate_properties_array(properties); + property_pool->deregister_particle(properties); } @@ -278,7 +278,7 @@ namespace Particles // If we haven't allocated memory yet, do so now if (properties == PropertyPool::invalid_handle) - properties = property_pool->allocate_properties_array(); + properties = property_pool->register_particle(); const ArrayView property_values = property_pool->get_properties(properties); @@ -309,7 +309,7 @@ namespace Particles // If this particle has no properties yet, allocate and initialize them. if (properties == PropertyPool::invalid_handle) { - properties = property_pool->allocate_properties_array(); + properties = property_pool->register_particle(); ArrayView my_properties = property_pool->get_properties(properties); diff --git a/source/particles/property_pool.cc b/source/particles/property_pool.cc index f204d83a01..1637aafab2 100644 --- a/source/particles/property_pool.cc +++ b/source/particles/property_pool.cc @@ -72,7 +72,7 @@ namespace Particles template typename PropertyPool::Handle - PropertyPool::allocate_properties_array() + PropertyPool::register_particle() { Handle handle = invalid_handle; if (n_properties > 0) @@ -96,7 +96,7 @@ namespace Particles template void - PropertyPool::deallocate_properties_array(Handle &handle) + PropertyPool::deregister_particle(Handle &handle) { Assert( handle != invalid_handle, diff --git a/tests/particles/property_pool_01.cc b/tests/particles/property_pool_01.cc index f34e8a3637..e530324f94 100644 --- a/tests/particles/property_pool_01.cc +++ b/tests/particles/property_pool_01.cc @@ -35,14 +35,14 @@ test() Particles::PropertyPool pool(1); typename Particles::PropertyPool::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; diff --git a/tests/particles/property_pool_02.cc b/tests/particles/property_pool_02.cc index 4cb2e9a9f7..0b7e83e7c8 100644 --- a/tests/particles/property_pool_02.cc +++ b/tests/particles/property_pool_02.cc @@ -36,7 +36,7 @@ test() Particles::PropertyPool pool(n_properties); typename Particles::PropertyPool::Handle handle = - pool.allocate_properties_array(); + pool.register_particle(); pool.get_properties(handle)[0] = 1.2; pool.get_properties(handle)[1] = 2.5; @@ -50,7 +50,7 @@ test() deallog << std::endl; - pool.deallocate_properties_array(handle); + pool.deregister_particle(handle); } deallog << "OK" << std::endl; -- 2.39.5