]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Clean up 13038/head
authorPeter Munch <peterrmuench@gmail.com>
Wed, 8 Dec 2021 08:11:59 +0000 (09:11 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Wed, 8 Dec 2021 08:11:59 +0000 (09:11 +0100)
include/deal.II/distributed/fully_distributed_tria.h
source/distributed/fully_distributed_tria.cc
source/grid/tria_description.cc

index 318e99f84e4f1495410766bba4e8482834224ca9..b6337f9a92845d8e95f2474eca131b74a5d5e3e2 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <deal.II/base/config.h>
 
+#include <deal.II/distributed/repartitioning_policy_tools.h>
 #include <deal.II/distributed/tria_base.h>
 
 #include <deal.II/grid/grid_tools.h>
@@ -39,12 +40,6 @@ namespace GridTools
   template <typename CellIterator>
   struct PeriodicFacePair;
 }
-
-namespace RepartitioningPolicyTools
-{
-  template <int dim, int spacedim>
-  class Base;
-}
 #endif
 
 namespace parallel
@@ -203,7 +198,8 @@ namespace parallel
         const TriangulationDescription::Settings &     settings);
 
       /**
-       * TODO
+       * Register a partitioner, which is used within the method
+       * repartition().
        */
       void
       set_partitioner(
@@ -211,7 +207,8 @@ namespace parallel
         const TriangulationDescription::Settings &            settings);
 
       /**
-       * TODO
+       * Execute repartitioning and use the partitioner attached by the
+       * method set_partitioner();
        */
       void
       repartition();
@@ -322,7 +319,7 @@ namespace parallel
         partitioner;
 
       /**
-       * TODO
+       * Partitioner used during repartition().
        */
       SmartPointer<const RepartitioningPolicyTools::Base<dim, spacedim>>
         partitioner_distributed;
index 7e6df2b8158184e5ac01601fb6c294be171734e5..ed8766a55f721577cee1bf89468e36847d138922 100644 (file)
@@ -327,20 +327,25 @@ namespace parallel
     void
     Triangulation<dim, spacedim>::repartition()
     {
+      // signal that repartitioning has started
       this->signals.pre_distributed_repartition();
 
+      // create construction_data with the help of the partitioner
       const auto construction_data = TriangulationDescription::Utilities::
         create_description_from_triangulation(
           *this,
           this->partitioner_distributed->partition(*this),
           this->settings);
 
+      // clear old content
       this->clear();
       this->coarse_cell_id_to_coarse_cell_index_vector.clear();
       this->coarse_cell_index_to_coarse_cell_id_vector.clear();
 
+      // use construction_data to set up new triangulation
       this->create_triangulation(construction_data);
 
+      // signal that repartitioning has completed
       this->signals.post_distributed_repartition();
     }
 
index e8c5041c0b514d2eccc3fb54207f35bb3acd7b1a..ceccb8d8e662bddac86261b9f0cad7facb1ba7fe 100644 (file)
@@ -158,8 +158,9 @@ namespace TriangulationDescription
           this->cell_infos.resize(
             std::max(other.cell_infos.size(), this->cell_infos.size()));
 
-          if (vertices_have_unique_ids == false)
+          if (vertices_have_unique_ids == false) // need to compare points
             {
+              // comparator of points
               const auto comp = [](const auto &a, const auto &b) {
                 const double tolerance = 1e-10;
 
@@ -170,31 +171,40 @@ namespace TriangulationDescription
                 return false;
               };
 
-              std::map<Point<spacedim>, unsigned int, decltype(comp)> map(comp);
-              std::map<unsigned int, unsigned int>                    map_i;
+              // map point to local vertex index
+              std::map<Point<spacedim>, unsigned int, decltype(comp)>
+                map_point_to_local_vertex_index(comp);
 
+              // ... initialize map with existing points
               for (unsigned int i = 0; i < this->coarse_cell_vertices.size();
                    ++i)
-                map[coarse_cell_vertices[i].second] = i;
+                map_point_to_local_vertex_index[coarse_cell_vertices[i]
+                                                  .second] = i;
 
-              unsigned int counter = coarse_cell_vertices.size();
+              // map local vertex indices within other to the new local indices
+              std::map<unsigned int, unsigned int>
+                map_old_to_new_local_vertex_index;
 
-              for (const auto p : other.coarse_cell_vertices)
-                if (map.find(p.second) == map.end())
+              // 1) renumerate vertices in other and insert into maps
+              unsigned int counter = coarse_cell_vertices.size();
+              for (const auto &p : other.coarse_cell_vertices)
+                if (map_point_to_local_vertex_index.find(p.second) ==
+                    map_point_to_local_vertex_index.end())
                   {
                     this->coarse_cell_vertices.emplace_back(counter, p.second);
-                    map[p.second] = map_i[p.first] = counter++;
+                    map_point_to_local_vertex_index[p.second] =
+                      map_old_to_new_local_vertex_index[p.first] = counter++;
                   }
                 else
-                  map_i[p.first] = map[p.second];
+                  map_old_to_new_local_vertex_index[p.first] =
+                    map_point_to_local_vertex_index[p.second];
 
+              // 2) renumerate vertices of cells
               auto other_coarse_cells_copy = other.coarse_cells;
 
               for (auto &cell : other_coarse_cells_copy)
-                {
-                  for (auto &v : cell.vertices)
-                    v = map_i[v];
-                }
+                for (auto &v : cell.vertices)
+                  v = map_old_to_new_local_vertex_index[v];
 
               this->coarse_cells.insert(this->coarse_cells.end(),
                                         other_coarse_cells_copy.begin(),

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.