From ca8168eed67f14b0b446d5413e2a2f8387e0f0fa Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Sun, 1 Mar 2020 20:57:45 -0500 Subject: [PATCH] address comments --- source/distributed/grid_refinement.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/distributed/grid_refinement.cc b/source/distributed/grid_refinement.cc index 4eb262fab7..e5aeeb0b21 100644 --- a/source/distributed/grid_refinement.cc +++ b/source/distributed/grid_refinement.cc @@ -256,16 +256,16 @@ namespace internal (interesting_range[0] + interesting_range[1]) / 2); // Count how many of our own elements would be above this - // threshold: - types::global_cell_index my_count = + // threshold. Use a 64bit result type if we are compiling with + // 64bit indices to avoid an overflow when computing the sum + // below. + const types::global_cell_index my_count = std::count_if(criteria.begin(), criteria.end(), [test_threshold](const double c) { return c > test_threshold; }); - - // Potentially accumulate in a 64bit int to avoid overflow: - types::global_cell_index total_count = + const types::global_cell_index total_count = Utilities::MPI::sum(my_count, mpi_communicator); // now adjust the range. if we have too many cells, we take the -- 2.39.5