From 9b4c1ed4b5960a7238edcbed804b1bf02df2034d Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sun, 16 Feb 2020 23:10:10 -0500 Subject: [PATCH] Fix overflow in tria.n_global_active_cells() for large computations. --- source/distributed/tria_base.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/distributed/tria_base.cc b/source/distributed/tria_base.cc index 87b76f80da..189be2a997 100644 --- a/source/distributed/tria_base.cc +++ b/source/distributed/tria_base.cc @@ -217,9 +217,12 @@ namespace parallel if (cell->subdomain_id() == my_subdomain) ++number_cache.n_locally_owned_active_cells; + // Potentially cast to a 64 bit type before accumulating to avoid overflow: number_cache.n_global_active_cells = - Utilities::MPI::sum(number_cache.n_locally_owned_active_cells, + Utilities::MPI::sum(static_cast( + number_cache.n_locally_owned_active_cells), this->mpi_communicator); + number_cache.n_global_levels = Utilities::MPI::max(this->n_levels(), this->mpi_communicator); } -- 2.39.5