]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix ghost duplication bug + apply Rene's comments
authorBruno <blais.bruno@gmail.com>
Wed, 9 Jun 2021 02:19:59 +0000 (22:19 -0400)
committerBruno <blais.bruno@gmail.com>
Wed, 9 Jun 2021 02:19:59 +0000 (22:19 -0400)
include/deal.II/particles/particle_handler.h
source/particles/particle_handler.cc

index 13382cc361ecf22a0877e8344ecdf72a521df609..411b41592238dff4d28b0f8664039152719420ad 100644 (file)
@@ -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;
 
index a8ca1601030700917f72fd9d7f3462649adaa719..07ff7504128523321f50ddff2f7f4fc3d2763cea 100644 (file)
@@ -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;
 

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.