]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix MinimalGranularityPolicy 12480/head
authorPeter Munch <peterrmuench@gmail.com>
Mon, 21 Jun 2021 14:37:23 +0000 (16:37 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Mon, 21 Jun 2021 14:37:23 +0000 (16:37 +0200)
source/distributed/repartitioning_policy_tools.cc

index d13b788d9043555f49dd9a2b1e052ae6104f02cb..a7e35036f42772e8ff6a3a16848b3faec8c7c6af 100644 (file)
@@ -208,10 +208,17 @@ namespace RepartitioningPolicyTools
       // the same number of cells; if there is a remainder, we assign the
       // first processes an additional cell (so that the difference of number of
       // locally owned cells is never larger than one between processes).
-      if (i < (i / min_cells) * min_cells + (n_global_active_cells % min_cells))
-        return i / (min_cells + 1);
-      else
-        return (i - (n_global_active_cells % min_cells)) / min_cells;
+      const unsigned int n_partitions_with_additional_cell =
+        n_global_active_cells - min_cells * n_partitions;
+
+      const unsigned int rank =
+        (i < (min_cells + 1) * n_partitions_with_additional_cell) ?
+          (i / (min_cells + 1)) :
+          ((i - n_partitions_with_additional_cell) / min_cells);
+
+      AssertIndexRange(rank, n_partitions);
+
+      return rank;
     };
 
     for (const auto i : partition.locally_owned_elements())

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.