From: Peter Munch Date: Thu, 3 Mar 2022 23:38:41 +0000 (+0100) Subject: Fix bugs in CellIDTranslator X-Git-Tag: v9.4.0-rc1~410^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13487%2Fhead;p=dealii.git Fix bugs in CellIDTranslator --- diff --git a/include/deal.II/grid/cell_id_translator.h b/include/deal.II/grid/cell_id_translator.h index 8dbbbf63ea..02166bacd0 100644 --- a/include/deal.II/grid/cell_id_translator.h +++ b/include/deal.II/grid/cell_id_translator.h @@ -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::max_children_per_cell, i) * - n_coarse_cells); + tree_sizes.push_back(tree_sizes.back() + + Utilities::pow( + GeometryInfo::max_children_per_cell, i) * + n_coarse_cells); } @@ -162,8 +162,8 @@ namespace internal CellIDTranslator::size() const { return n_coarse_cells * - (Utilities::pow(GeometryInfo::max_children_per_cell, - n_global_levels) - + (Utilities::pow( + GeometryInfo::max_children_per_cell, n_global_levels) - 1); } diff --git a/source/base/mpi_compute_index_owner_internal.cc b/source/base/mpi_compute_index_owner_internal.cc index 159e746234..4658c520aa 100644 --- a/source/base/mpi_compute_index_owner_internal.cc +++ b/source/base/mpi_compute_index_owner_internal.cc @@ -146,21 +146,21 @@ namespace Utilities // smaller pieces in terms of the dictionary number. std::pair 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; }