From: Timo Heister Date: Mon, 17 Feb 2020 04:10:10 +0000 (-0500) Subject: Fix overflow in tria.n_global_active_cells() X-Git-Tag: v9.2.0-rc1~513^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b4c1ed4b5960a7238edcbed804b1bf02df2034d;p=dealii.git Fix overflow in tria.n_global_active_cells() for large computations. --- 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); }