]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Change default number of properties
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Sat, 5 May 2018 19:41:15 +0000 (12:41 -0700)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Sat, 5 May 2018 19:45:16 +0000 (12:45 -0700)
include/deal.II/particles/property_pool.h
source/particles/property_pool.cc
tests/particles/particle_04.cc
tests/particles/property_pool_01.cc

index ef452c81dc9d37d5f8bbb830e3ef43f5ebcc4f79..7fb22f1ab6a1359ca44cd82f3f1cf083acbe0918 100644 (file)
@@ -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 ();
 
index 68b13ed19252fb59308d8cd37ea1e501e3e666b6..2eb75114699b3db102eadf50493f08a365c31794 100644 (file)
@@ -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;
   }
 
 
index 49a6b6b0e070241a81db8ef50c5ba23f1251055d..99fabb67ecd6cf6114e41b7b0b23ab088f280514 100644 (file)
@@ -55,7 +55,7 @@ void test ()
     particle.write_data(write_pointer);
 
     const void *read_pointer = static_cast<const void *> (&data.front());
-    Particles::PropertyPool pool(0);
+    Particles::PropertyPool pool;
     const Particles::Particle<dim,spacedim> new_particle(read_pointer,pool);
 
     deallog << "Copy particle location: " << new_particle.get_location() << std::endl
index e078ed98ecd5441729cd7ca3cd6f2be13973d784..e405cb2f38aedb50e73be4e5c6599470f653d603 100644 (file)
@@ -26,7 +26,7 @@
 void test ()
 {
   {
-    Particles::PropertyPool pool;
+    Particles::PropertyPool pool(1);
 
     typename Particles::PropertyPool::Handle handle = pool.allocate_properties_array();
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.