From 5f870260544c0c56484b3c3e0e111a666b148d29 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 19 Oct 2020 19:26:05 -0600 Subject: [PATCH] Move the order of member variables in ParticleHandler around. --- include/deal.II/particles/particle_handler.h | 16 ++++++++++------ source/particles/particle_handler.cc | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/deal.II/particles/particle_handler.h b/include/deal.II/particles/particle_handler.h index fd0b345fd1..5752de864e 100644 --- a/include/deal.II/particles/particle_handler.h +++ b/include/deal.II/particles/particle_handler.h @@ -786,6 +786,16 @@ namespace Particles SmartPointer, ParticleHandler> 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 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 property_pool; - /** * A function that can be registered by calling * register_additional_store_load_functions. It is called when serializing diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 2376c51dc0..7261572fa3 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -87,12 +87,12 @@ namespace Particles template ParticleHandler::ParticleHandler() : triangulation() + , property_pool(std::make_unique(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(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(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(n_properties)) , size_callback() , store_callback() , load_callback() -- 2.39.5