From 494ac530650c46f57904a52a5d7fd837c0ad5d45 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Sat, 5 May 2018 12:41:15 -0700 Subject: [PATCH] Change default number of properties --- include/deal.II/particles/property_pool.h | 5 +++-- source/particles/property_pool.cc | 6 +++++- tests/particles/particle_04.cc | 2 +- tests/particles/property_pool_01.cc | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/deal.II/particles/property_pool.h b/include/deal.II/particles/property_pool.h index ef452c81dc..7fb22f1ab6 100644 --- a/include/deal.II/particles/property_pool.h +++ b/include/deal.II/particles/property_pool.h @@ -56,11 +56,12 @@ namespace Particles /** * Constructor. Stores the number of properties per reserved slot. */ - PropertyPool (const unsigned int n_properties_per_slot=1); + PropertyPool (const unsigned int n_properties_per_slot); /** * Return a new handle that allows accessing the reserved block - * of memory. + * of memory. If the number of properties is zero this will return an + * invalid handle. */ Handle allocate_properties_array (); diff --git a/source/particles/property_pool.cc b/source/particles/property_pool.cc index 68b13ed192..2eb7511469 100644 --- a/source/particles/property_pool.cc +++ b/source/particles/property_pool.cc @@ -33,7 +33,11 @@ namespace Particles PropertyPool::Handle PropertyPool::allocate_properties_array () { - return new double[n_properties]; + PropertyPool::Handle handle = PropertyPool::invalid_handle; + if (n_properties > 0) + handle = new double[n_properties]; + + return handle; } diff --git a/tests/particles/particle_04.cc b/tests/particles/particle_04.cc index 49a6b6b0e0..99fabb67ec 100644 --- a/tests/particles/particle_04.cc +++ b/tests/particles/particle_04.cc @@ -55,7 +55,7 @@ void test () particle.write_data(write_pointer); const void *read_pointer = static_cast (&data.front()); - Particles::PropertyPool pool(0); + Particles::PropertyPool pool; const Particles::Particle new_particle(read_pointer,pool); deallog << "Copy particle location: " << new_particle.get_location() << std::endl diff --git a/tests/particles/property_pool_01.cc b/tests/particles/property_pool_01.cc index e078ed98ec..e405cb2f38 100644 --- a/tests/particles/property_pool_01.cc +++ b/tests/particles/property_pool_01.cc @@ -26,7 +26,7 @@ void test () { { - Particles::PropertyPool pool; + Particles::PropertyPool pool(1); typename Particles::PropertyPool::Handle handle = pool.allocate_properties_array(); -- 2.39.5