]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix bugs in CellIDTranslator 13487/head
authorPeter Munch <peterrmuench@gmail.com>
Thu, 3 Mar 2022 23:38:41 +0000 (00:38 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 4 Mar 2022 14:58:07 +0000 (15:58 +0100)
include/deal.II/grid/cell_id_translator.h
source/base/mpi_compute_index_owner_internal.cc

index 8dbbbf63ea837981dfd5d0cade029b6072356497..02166bacd058f8bc73bcdd5cb6f7f745c4dbebc9 100644 (file)
@@ -149,10 +149,10 @@ namespace internal
 
     tree_sizes.push_back(0);
     for (unsigned int i = 0; i < n_global_levels; ++i)
-      tree_sizes.push_back(
-        tree_sizes.back() +
-        Utilities::pow(GeometryInfo<dim>::max_children_per_cell, i) *
-          n_coarse_cells);
+      tree_sizes.push_back(tree_sizes.back() +
+                           Utilities::pow<types::global_cell_index>(
+                             GeometryInfo<dim>::max_children_per_cell, i) *
+                             n_coarse_cells);
   }
 
 
@@ -162,8 +162,8 @@ namespace internal
   CellIDTranslator<dim>::size() const
   {
     return n_coarse_cells *
-           (Utilities::pow(GeometryInfo<dim>::max_children_per_cell,
-                           n_global_levels) -
+           (Utilities::pow<types::global_cell_index>(
+              GeometryInfo<dim>::max_children_per_cell, n_global_levels) -
             1);
   }
 
index 159e746234f33170ff1448350d26b7d503607134..4658c520aa96840834d43aff562dedbe2cd32990 100644 (file)
@@ -146,21 +146,21 @@ namespace Utilities
               // smaller pieces in terms of the dictionary number.
               std::pair<types::global_dof_index, types::global_dof_index>
                 index_range(*interval->begin(), interval->last() + 1);
-              const unsigned int owner_last =
-                dof_to_dict_rank(interval->last());
-              unsigned int owner_first = numbers::invalid_unsigned_int;
-              while (owner_first != owner_last)
+
+              AssertThrow(index_range.second <= size, ExcInternalError());
+
+              while (index_range.first != index_range.second)
                 {
                   Assert(index_range.first < index_range.second,
                          ExcInternalError());
 
-                  owner_first = dof_to_dict_rank(index_range.first);
+                  const unsigned int owner =
+                    dof_to_dict_rank(index_range.first);
 
                   // this explicitly picks up the formula of
                   // dof_to_dict_rank, so the two places must be in sync
-                  types::global_dof_index next_index =
-                    std::min(get_index_offset(owner_first + 1),
-                             index_range.second);
+                  const types::global_dof_index next_index =
+                    std::min(get_index_offset(owner + 1), index_range.second);
 
                   Assert(next_index > index_range.first, ExcInternalError());
 
@@ -170,12 +170,12 @@ namespace Utilities
                   for (types::global_dof_index i = index_range.first + 1;
                        i < next_index;
                        ++i)
-                    AssertDimension(owner_first, dof_to_dict_rank(i));
+                    AssertDimension(owner, dof_to_dict_rank(i));
 #  endif
 
                   // add the interval, either to the local range or into a
                   // buffer to be sent to another processor
-                  if (owner_first == my_rank)
+                  if (owner == my_rank)
                     {
                       std::fill(actually_owning_ranks.data() +
                                   index_range.first - local_range.first,
@@ -187,8 +187,7 @@ namespace Utilities
                         actually_owning_rank_list.push_back(my_rank);
                     }
                   else
-                    buffers[owner_first].emplace_back(index_range.first,
-                                                      next_index);
+                    buffers[owner].emplace_back(index_range.first, next_index);
 
                   index_range.first = next_index;
                 }

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.