]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bug in sort_particles_into_subdomains_and_cells
authorMartin Kronbichler <martin.kronbichler@it.uu.se>
Fri, 5 Nov 2021 21:59:33 +0000 (22:59 +0100)
committerMartin Kronbichler <martin.kronbichler@it.uu.se>
Fri, 5 Nov 2021 21:59:33 +0000 (22:59 +0100)
source/particles/particle_handler.cc

index c00f560faf3f9d9051c595a3776bacfe899610b1..d1ea72c6ec6680ac9249f106536a24e211bfe9c0 100644 (file)
@@ -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<dim, spacedim>::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<dim, spacedim>::invalid_handle;
+
+              // Allocate particle with the old handle
+              insert_particle(old_value, current_cell);
             }
           else
             {

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.