From: Rene Gassmoeller Date: Fri, 29 Apr 2022 14:44:35 +0000 (-0400) Subject: Make indent and improve test documentation. X-Git-Tag: v9.4.0-rc1~293^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13654%2Fhead;p=dealii.git Make indent and improve test documentation. --- diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 1aaed11693..9a0adde420 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -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(); diff --git a/tests/particles/particle_handler_22.cc b/tests/particles/particle_handler_22.cc index 5274f792dd..ba3c6bd5cf 100644 --- a/tests/particles/particle_handler_22.cc +++ b/tests/particles/particle_handler_22.cc @@ -14,13 +14,11 @@ * --------------------------------------------------------------------- * 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 void ParticleTracking::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 center_of_triangulation; center_of_triangulation[0] = 0.; center_of_triangulation[1] = 0.; @@ -137,9 +134,7 @@ ParticleTracking::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 center_of_particles; center_of_particles[0] = 0.0; center_of_particles[1] = 0.0; @@ -235,11 +230,43 @@ ParticleTracking::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(); } } diff --git a/tests/particles/particle_handler_22.with_p4est=true.mpirun=2.output b/tests/particles/particle_handler_22.with_p4est=true.mpirun=2.output index 4c59b55710..a50170d7d9 100644 --- a/tests/particles/particle_handler_22.with_p4est=true.mpirun=2.output +++ b/tests/particles/particle_handler_22.with_p4est=true.mpirun=2.output @@ -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