]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move the order of member variables in ParticleHandler around.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 20 Oct 2020 01:26:05 +0000 (19:26 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 20 Oct 2020 02:44:36 +0000 (20:44 -0600)
include/deal.II/particles/particle_handler.h
source/particles/particle_handler.cc

index fd0b345fd11650d80638b784a486485a4c86ff50..5752de864e5c6d53b838d4cdee1e7883370161ff 100644 (file)
@@ -786,6 +786,16 @@ namespace Particles
     SmartPointer<const Mapping<dim, spacedim>, ParticleHandler<dim, spacedim>>
       mapping;
 
+    /**
+     * This object owns and organizes the memory for all particle
+     * properties. Since particles reference the property pool, the
+     * latter has to be destroyed *after* the particles are destroyed.
+     * This is achieved by making sure the `property_pool` member variable
+     * precedes the declaration of the `particles` and `ghost_particles`
+     * members.
+     */
+    std::unique_ptr<PropertyPool> property_pool;
+
     /**
      * Set of particles currently living in the local domain, organized by
      * the level/index of the cell they are in.
@@ -821,12 +831,6 @@ namespace Particles
      */
     types::particle_index next_free_particle_index;
 
-    /**
-     * This object owns and organizes the memory for all particle
-     * properties.
-     */
-    std::unique_ptr<PropertyPool> property_pool;
-
     /**
      * A function that can be registered by calling
      * register_additional_store_load_functions. It is called when serializing
index 2376c51dc0d2e12ee19620cd0112521822dc74f4..7261572fa36c0e73fc40a12c3d47d9b61ccaef10 100644 (file)
@@ -87,12 +87,12 @@ namespace Particles
   template <int dim, int spacedim>
   ParticleHandler<dim, spacedim>::ParticleHandler()
     : triangulation()
+    , property_pool(std::make_unique<PropertyPool>(0))
     , particles()
     , ghost_particles()
     , global_number_of_particles(0)
     , global_max_particles_per_cell(0)
     , next_free_particle_index(0)
-    , property_pool(std::make_unique<PropertyPool>(0))
     , size_callback()
     , store_callback()
     , load_callback()
@@ -108,12 +108,12 @@ namespace Particles
     const unsigned int                  n_properties)
     : triangulation(&triangulation, typeid(*this).name())
     , mapping(&mapping, typeid(*this).name())
+    , property_pool(std::make_unique<PropertyPool>(n_properties))
     , particles()
     , ghost_particles()
     , global_number_of_particles(0)
     , global_max_particles_per_cell(0)
     , next_free_particle_index(0)
-    , property_pool(std::make_unique<PropertyPool>(n_properties))
     , size_callback()
     , store_callback()
     , load_callback()

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.