From: Bruno Date: Wed, 9 Jun 2021 02:19:59 +0000 (-0400) Subject: Fix ghost duplication bug + apply Rene's comments X-Git-Tag: v9.4.0-rc1~1248^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0837e4ed53ec4f4db1fc8fa8460ceccfecbc9f75;p=dealii.git Fix ghost duplication bug + apply Rene's comments --- diff --git a/include/deal.II/particles/particle_handler.h b/include/deal.II/particles/particle_handler.h index 13382cc361..411b415922 100644 --- a/include/deal.II/particles/particle_handler.h +++ b/include/deal.II/particles/particle_handler.h @@ -809,7 +809,7 @@ namespace Particles /** * Set of particles currently living in the local domain including ghost - * cells , organized by the active cell of the cell they are in. + * cells, organized by the active cell of the cell they are in. */ particle_container particles; diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index a8ca160103..07ff750412 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -1066,10 +1066,10 @@ namespace Particles const unsigned int n_pic = particles[active_cell_index].size(); // Particles can be inserted into arbitrary cells, e.g. if their cell is - // not known. However, for artificial cells we can not check evaluate - // the reference position of particles and particles in ghost cells - // should not be owned by this process. Assume all particles that are in - // not locally owned cells have to be resorted or transferred. + // not known. However, for artificial cells we can not evaluate + // the reference position of particles. Do not sort particles that are + // not locally owned, because they will be sorted by the process that + // owns them. if (cell->is_locally_owned() == false) { continue; @@ -1308,6 +1308,19 @@ namespace Particles #ifndef DEAL_II_WITH_MPI (void)enable_cache; #else + // Clear ghost particles and their properties + for (const auto &cell : triangulation->active_cell_iterators()) + if (cell->is_locally_owned() == false) + { + // Clear particle properties + for (auto &ghost_particle : particles[cell->active_cell_index()]) + property_pool->deregister_particle(ghost_particle); + + // Clear particles themselves + particles[cell->active_cell_index()].clear(); + } + + // Clear ghost particles cache and invalidate it ghost_particles_cache.ghost_particles_by_domain.clear(); ghost_particles_cache.valid = false;