From: Martin Kronbichler Date: Fri, 5 Nov 2021 21:59:33 +0000 (+0100) Subject: Fix bug in sort_particles_into_subdomains_and_cells X-Git-Tag: v9.4.0-rc1~849^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88bf50445f74835853cc7faec9f7c0c389207c9e;p=dealii.git Fix bug in sort_particles_into_subdomains_and_cells --- 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 {