From 88bf50445f74835853cc7faec9f7c0c389207c9e Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 5 Nov 2021 22:59:33 +0100 Subject: [PATCH] Fix bug in sort_particles_into_subdomains_and_cells --- source/particles/particle_handler.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index c00f560faf..d1ea72c6ec 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -208,9 +208,9 @@ namespace Particles cells_to_particle_cache.clear(); if (triangulation != nullptr) { + reset_particle_container(&*triangulation, particles); cells_to_particle_cache.resize(triangulation->n_active_cells(), particles.end()); - reset_particle_container(&*triangulation, particles); } else reset_particle_container(nullptr, particles); @@ -1393,13 +1393,16 @@ namespace Particles // Mark it for MPI transfer otherwise if (current_cell->is_locally_owned()) { - auto &old = + typename PropertyPool::Handle &old = out_particle->particles_in_cell ->particles[out_particle->particle_index_within_cell]; - insert_particle(old, current_cell); // Avoid deallocating the memory of this particle + const auto old_value = old; old = PropertyPool::invalid_handle; + + // Allocate particle with the old handle + insert_particle(old_value, current_cell); } else { -- 2.39.5