]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make indent and improve test documentation. 13654/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 29 Apr 2022 14:44:35 +0000 (10:44 -0400)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 29 Apr 2022 14:44:35 +0000 (10:44 -0400)
source/particles/particle_handler.cc
tests/particles/particle_handler_22.cc
tests/particles/particle_handler_22.with_p4est=true.mpirun=2.output

index 1aaed11693b78d14c8ce2a76febbedb03a340e64..9a0adde42034535f84319a6b6c7371dc1a375eb0 100644 (file)
@@ -301,7 +301,8 @@ namespace Particles
               {
                 // before we move the sorted_particles into particles
                 // particle_container_ghost_end() still points to the
-                // old particles container. Therefore this condition looks quirky.
+                // old particles container. Therefore this condition looks
+                // quirky.
                 typename particle_container::iterator insert_position =
                   cell->is_locally_owned() ? particle_container_owned_end() :
                                              --sorted_particles.end();
index 5274f792dd6d1ff65ff42fc881e6b918e525444f..ba3c6bd5cf7a68ca70ae27a6cc2227783f116647 100644 (file)
  * ---------------------------------------------------------------------
 
  * This test case is an extremely simplified version of step-68.
- * A ball made of 48 particles is generated. This ball is moved down slightly.
- * The particles remain in the simulation domain and they should not disappear.
- * At the moment of the creation of this test, a bug in the particle_handler
- would
- * make one particle disappear and the number would decrease from 48 to 47 at
- the
- * second time step.
+ * A ball made of 48 particles is generated and the test is run on
+ * multiple MPI ranks. After particle movement ghost particles are
+ * exchanged between the ranks. This test was created to reproduce a
+ * bug that would delete ghost particles when sorting particles into
+ * their new cells after movement.
  */
 
 // Include files
@@ -117,8 +115,7 @@ template <int dim>
 void
 ParticleTracking<dim>::generate_particles()
 {
-  // We create an hyper ball triangulation which we globally refine. The bug
-  // that this test tries to reproduce only occured in curevd geometry.
+  // We create an hyper ball triangulation which we globally refine.
   Point<dim> center_of_triangulation;
   center_of_triangulation[0] = 0.;
   center_of_triangulation[1] = 0.;
@@ -137,9 +134,7 @@ ParticleTracking<dim>::generate_particles()
   // We create a particle triangulation which is solely used to generate
   // the points which will be used to insert the particles. This
   // triangulation is a hyper shell which is in the center
-  // of the domain to generate ghost particles. We generate enough particle to
-  // reproduce the bug.
-
+  // of the domain to generate ghost particles.
   Point<dim> center_of_particles;
   center_of_particles[0] = 0.0;
   center_of_particles[1] = 0.0;
@@ -235,11 +230,43 @@ ParticleTracking<dim>::run()
 
       euler_step_analytical(discrete_time.get_previous_step_size());
 
-      unsigned int n_part_before_sort = particle_handler.n_global_particles();
+      unsigned int n_ghost_particles = 0;
+      for (auto ghost_particle = particle_handler.begin_ghost();
+           ghost_particle != particle_handler.end_ghost();
+           ++ghost_particle)
+        {
+          ++n_ghost_particles;
+        }
+
+      deallog << "Number of ghost particles before sort: "
+              << std::to_string(n_ghost_particles) << std::endl;
 
       particle_handler.sort_particles_into_subdomains_and_cells();
+
+      n_ghost_particles = 0;
+      for (auto ghost_particle = particle_handler.begin_ghost();
+           ghost_particle != particle_handler.end_ghost();
+           ++ghost_particle)
+        {
+          ++n_ghost_particles;
+        }
+
+      deallog << "Number of ghost particles after sort: "
+              << std::to_string(n_ghost_particles) << std::endl;
+
       particle_handler.exchange_ghost_particles(false);
 
+      n_ghost_particles = 0;
+      for (auto ghost_particle = particle_handler.begin_ghost();
+           ghost_particle != particle_handler.end_ghost();
+           ++ghost_particle)
+        {
+          ++n_ghost_particles;
+        }
+
+      deallog << "Number of ghost particles after exchange: "
+              << std::to_string(n_ghost_particles) << std::endl;
+
       unsigned int n_part_after_sort = particle_handler.n_global_particles();
     }
 }
index 4c59b55710f1f62a7848db6f8a66d4d0ebeab48c..a50170d7d981c1cf5f99d914245a83ce8bc24045 100644 (file)
@@ -1,5 +1,23 @@
 
 DEAL:0::Number of particles inserted: 48
+DEAL:0::Number of ghost particles before sort: 0
+DEAL:0::Number of ghost particles after sort: 0
+DEAL:0::Number of ghost particles after exchange: 4
+DEAL:0::Number of ghost particles before sort: 4
+DEAL:0::Number of ghost particles after sort: 4
+DEAL:0::Number of ghost particles after exchange: 4
+DEAL:0::Number of ghost particles before sort: 4
+DEAL:0::Number of ghost particles after sort: 4
+DEAL:0::Number of ghost particles after exchange: 7
 
 DEAL:1::Number of particles inserted: 48
+DEAL:1::Number of ghost particles before sort: 0
+DEAL:1::Number of ghost particles after sort: 0
+DEAL:1::Number of ghost particles after exchange: 0
+DEAL:1::Number of ghost particles before sort: 0
+DEAL:1::Number of ghost particles after sort: 0
+DEAL:1::Number of ghost particles after exchange: 0
+DEAL:1::Number of ghost particles before sort: 0
+DEAL:1::Number of ghost particles after sort: 0
+DEAL:1::Number of ghost particles after exchange: 0
 

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.