From de9069b28db4e72ed524d22694fc726dbe4643fe Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 7 Jan 2019 13:07:06 -0700 Subject: [PATCH] Some cleanups in GridTools. --- source/grid/grid_tools.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 2da178fa23..57717e4e48 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -5081,6 +5081,8 @@ namespace GridTools #endif // DEAL_II_WITH_MPI } + + template RTree, unsigned int>> build_global_description_tree( @@ -5096,17 +5098,17 @@ namespace GridTools return RTree, unsigned int>>{}; #else // Exchanging local bounding boxes - std::vector>> global_bboxes; - global_bboxes = + const std::vector>> global_bboxes = Utilities::MPI::all_gather(mpi_communicator, local_description); // Preparing to flatten the vector - unsigned int n_procs = Utilities::MPI::n_mpi_processes(mpi_communicator); - unsigned int tot_bboxes = 0; - // The i element of the following vector contains the index of the first + const unsigned int n_procs = + Utilities::MPI::n_mpi_processes(mpi_communicator); + // The i'th element of the following vector contains the index of the first // local bounding box from the process of rank i std::vector bboxes_position(n_procs); + unsigned int tot_bboxes = 0; for (const auto &process_bboxes : global_bboxes) tot_bboxes += process_bboxes.size(); @@ -5117,9 +5119,10 @@ namespace GridTools unsigned int process_index = 0; for (const auto &process_bboxes : global_bboxes) { - // Initializing a vector containing bounding boxes and rank of a process + // Initialize a vector containing bounding boxes and rank of a process std::vector, unsigned int>> boxes_and_indices(process_bboxes.size()); + // Adding to each box the rank of the process owning it for (unsigned int i = 0; i < process_bboxes.size(); ++i) boxes_and_indices[i] = @@ -5128,14 +5131,14 @@ namespace GridTools flat_global_bboxes.insert(flat_global_bboxes.end(), boxes_and_indices.begin(), boxes_and_indices.end()); + ++process_index; } - // Building a tree out of the bounding boxes - // We avoid using the insert method so that boost uses the packing algorithm - RTree, unsigned int>> r_tree( + // Build a tree out of the bounding boxes. We avoid using the + // insert method so that boost uses the packing algorithm + return RTree, unsigned int>>( flat_global_bboxes.begin(), flat_global_bboxes.end()); - return r_tree; #endif // DEAL_II_WITH_MPI } -- 2.39.5