From 841b136045a494c1ad5c84ccac29145861b8103e Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 30 May 2022 17:06:11 +0200 Subject: [PATCH] Fix bug for global coarsening: Must allow invalid proc id --- include/deal.II/base/mpi_compute_index_owner_internal.h | 4 +++- source/base/mpi_compute_index_owner_internal.cc | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/deal.II/base/mpi_compute_index_owner_internal.h b/include/deal.II/base/mpi_compute_index_owner_internal.h index 88ea9c88bd..195b19e155 100644 --- a/include/deal.II/base/mpi_compute_index_owner_internal.h +++ b/include/deal.II/base/mpi_compute_index_owner_internal.h @@ -45,7 +45,9 @@ namespace Utilities FlexibleIndexStorage(const bool use_vector = true); void - reinit(const bool use_vector, const std::size_t size); + reinit(const bool use_vector, + const bool index_range_contiguous, + const std::size_t size); void fill(const std::size_t start, diff --git a/source/base/mpi_compute_index_owner_internal.cc b/source/base/mpi_compute_index_owner_internal.cc index 53ad820a52..c70898afa8 100644 --- a/source/base/mpi_compute_index_owner_internal.cc +++ b/source/base/mpi_compute_index_owner_internal.cc @@ -44,6 +44,7 @@ namespace Utilities void FlexibleIndexStorage::reinit(const bool use_vector, + const bool index_range_contiguous, const std::size_t size) { this->use_vector = use_vector; @@ -52,8 +53,10 @@ namespace Utilities data = {}; data_map.clear(); - // do not initialize the vector but only upon first request in - // `fill` + // in case we have contiguous indices, only fill the vector upon + // first request in `fill` + if (!index_range_contiguous) + data.resize(size, invalid_index_value); } @@ -263,6 +266,8 @@ namespace Utilities actually_owning_ranks.reinit((owned_indices_size_actual * sparsity_factor) > owned_indices.size(), + owned_indices_size_actual == + owned_indices.size(), locally_owned_size); // 2) collect relevant processes and process local dict entries -- 2.39.5