]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Some cleanups in GridTools. 7568/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 7 Jan 2019 20:07:06 +0000 (13:07 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 7 Jan 2019 20:07:06 +0000 (13:07 -0700)
source/grid/grid_tools.cc

index 2da178fa23efda55975c49680e902b86f495b7c0..57717e4e48f10b36a3a6dd09863e17804070a85f 100644 (file)
@@ -5081,6 +5081,8 @@ namespace GridTools
 #endif // DEAL_II_WITH_MPI
   }
 
+
+
   template <int spacedim>
   RTree<std::pair<BoundingBox<spacedim>, unsigned int>>
   build_global_description_tree(
@@ -5096,17 +5098,17 @@ namespace GridTools
     return RTree<std::pair<BoundingBox<spacedim>, unsigned int>>{};
 #else
     // Exchanging local bounding boxes
-    std::vector<std::vector<BoundingBox<spacedim>>> global_bboxes;
-    global_bboxes =
+    const std::vector<std::vector<BoundingBox<spacedim>>> 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<unsigned int> 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<std::pair<BoundingBox<spacedim>, 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<std::pair<BoundingBox<spacedim>, 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<std::pair<BoundingBox<spacedim>, unsigned int>>(
       flat_global_bboxes.begin(), flat_global_bboxes.end());
-    return r_tree;
 #endif // DEAL_II_WITH_MPI
   }
 

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.