]> https://gitweb.dealii.org/ - dealii.git/commitdiff
More use cases of new iterator 12433/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 10 Jun 2021 14:20:25 +0000 (16:20 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 10 Jun 2021 14:20:25 +0000 (16:20 +0200)
source/particles/particle_handler.cc

index 8b1d941d400bf7b7e37c26e4f0c78e3dacef74bf..3ce4213b6dca90a4fd8f848f7f950f6277fb8d5f 100644 (file)
@@ -348,7 +348,7 @@ namespace Particles
     if (container.size() > 1)
       {
         container[particle->particle_index_within_cell] =
-          std::move(particles[particle->cell->active_cell_index()].back());
+          std::move(container.back());
         container.resize(particles.size() - 1);
       }
     else
@@ -369,26 +369,27 @@ namespace Particles
   {
     unsigned int n_particles_removed = 0;
 
-    for (unsigned int cell_index = 0; cell_index < particles.size();
-         ++cell_index)
+    for (auto particles_on_cell = particles.begin();
+         particles_on_cell != particles.end();
+         ++particles_on_cell)
       {
         // If there is nothing left to remove, break and return
         if (n_particles_removed == particles_to_remove.size())
           break;
 
         // Skip cells where there is nothing to remove
-        if (particles_to_remove[n_particles_removed]
-              ->cell->active_cell_index() != cell_index)
+        if (particles_to_remove[n_particles_removed]->particles_on_cell !=
+            particles_on_cell)
           continue;
 
-        const unsigned int n_particles_in_cell = particles[cell_index].size();
+        const unsigned int n_particles_in_cell = particles_on_cell->size();
         unsigned int       move_to             = 0;
         for (unsigned int move_from = 0; move_from < n_particles_in_cell;
              ++move_from)
           {
             if (n_particles_removed != particles_to_remove.size() &&
-                particles_to_remove[n_particles_removed]
-                    ->cell->active_cell_index() == cell_index &&
+                particles_to_remove[n_particles_removed]->particles_on_cell ==
+                  particles_on_cell &&
                 particles_to_remove[n_particles_removed]
                     ->particle_index_within_cell == move_from)
               {
@@ -405,12 +406,12 @@ namespace Particles
               }
             else
               {
-                particles[cell_index][move_to] =
-                  std::move(particles[cell_index][move_from]);
+                (*particles_on_cell)[move_to] =
+                  std::move((*particles_on_cell)[move_from]);
                 ++move_to;
               }
           }
-        particles[cell_index].resize(move_to);
+        particles_on_cell->resize(move_to);
       }
 
     update_cached_numbers();
@@ -1251,13 +1252,13 @@ namespace Particles
                 current_cell->active_cell_index();
 
               particles[active_cell_index].push_back(
-                particles[out_particle->cell->active_cell_index()]
-                         [out_particle->particle_index_within_cell]);
+                (*out_particle->particles_on_cell)
+                  [out_particle->particle_index_within_cell]);
 
               // Avoid deallocating the memory of this particle
-              particles[out_particle->cell->active_cell_index()]
-                       [out_particle->particle_index_within_cell] =
-                         PropertyPool<dim, spacedim>::invalid_handle;
+              (*out_particle->particles_on_cell)
+                [out_particle->particle_index_within_cell] =
+                  PropertyPool<dim, spacedim>::invalid_handle;
             }
           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.