From 6bbcdc8cb11cf9818ee45dd5c7bf7fd3078d719a Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Tue, 3 Dec 2019 08:38:36 +0100 Subject: [PATCH] Applied suggestions. --- include/deal.II/particles/particle_handler.h | 15 +++++-------- source/particles/particle_handler.cc | 23 +++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/include/deal.II/particles/particle_handler.h b/include/deal.II/particles/particle_handler.h index 1ce0eabac3..67fb4b5e09 100644 --- a/include/deal.II/particles/particle_handler.h +++ b/include/deal.II/particles/particle_handler.h @@ -17,20 +17,15 @@ #define dealii_particles_particle_handler_h #include -#include +#include #include #include #include -#include #include #include -#include -#include -#include - #include #include #include @@ -227,7 +222,7 @@ namespace Particles * This function takes a list of positions and creates a set of particles * at these positions, which are then added to the local particle * collection. Note that this function currently uses - * GridTools::compute_point_locations, which assumes all positions are + * GridTools::compute_point_locations(), which assumes all positions are * within the local part of the triangulation. If one of them is not in the * local domain this function will throw an exception. */ @@ -242,11 +237,11 @@ namespace Particles * GridTools::distributed_compute_point_locations. Consequently, it can * require intense communications between the processors. * - * This function figures out what mpi process owns all points that do not + * This function figures out what mpi process owns the points that do not * fall within the locally owned part of the triangulation, it sends * to that process the points passed to this function on this process, * and receives the points that fall within the locally owned cells of - * the triangulation from whoever owns them. + * the triangulation from whoever received them as input. * * In order to keep track of what mpi process received what points, a map * from mpi process to IndexSet is returned by the function. This IndexSet @@ -292,7 +287,7 @@ namespace Particles const std::vector> &positions, const std::vector>> & global_bounding_boxes, - const std::vector &properties = std::vector()); + const std::vector &properties = {}); /** * This function allows to register three additional functions that are diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 555ecd3bb9..31364e4921 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -463,7 +463,7 @@ namespace Particles GridTools::Cache cache(*triangulation, *mapping); // Gather the number of points per processor - auto n_particles_per_proc = + const auto n_particles_per_proc = Utilities::MPI::all_gather(triangulation->get_communicator(), positions.size()); @@ -478,37 +478,34 @@ namespace Particles particle_start_index += n_particles_per_proc[process]; } - auto distributed_tuple = + const auto distributed_tuple = GridTools::distributed_compute_point_locations(cache, positions, global_bounding_boxes); // Finally create the particles - std::vector::active_cell_iterator> - local_cells_containing_particles = std::get<0>(distributed_tuple); + const auto &local_cells_containing_particles = + std::get<0>(distributed_tuple); // The reference position of every particle in the local part of the // triangulation. - std::vector>> local_reference_positions = - std::get<1>(distributed_tuple); + const auto &local_reference_positions = std::get<1>(distributed_tuple); // The original index in the positions vector for each particle in the local // part of the triangulation - std::vector> origin_indices_of_local_particles = + const auto &original_indices_of_local_particles = std::get<2>(distributed_tuple); // The real spatial position of every particle in the local part of the // triangulation. - std::vector>> local_positions = - std::get<3>(distributed_tuple); + const auto &local_positions = std::get<3>(distributed_tuple); // The MPI process that inserted each particle - std::vector> calling_process_index = - std::get<4>(distributed_tuple); + const auto &calling_process_index = std::get<4>(distributed_tuple); // Create the multimap of local particles std::multimap::active_cell_iterator, Particle> particles; - // Create the map of cpu to indices, indicating whom sent us what + // Create the map of cpu to indices, indicating who sent us what // point std::map origin_process_to_local_particle_indices; @@ -521,7 +518,7 @@ namespace Particles ++i_particle) { const auto &local_id_on_calling_process = - origin_indices_of_local_particles[i_cell][i_particle]; + original_indices_of_local_particles[i_cell][i_particle]; const auto &calling_process = calling_process_index[i_cell][i_particle]; -- 2.39.5