]> https://gitweb.dealii.org/ - dealii.git/commitdiff
address comments 9585/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 2 Mar 2020 01:57:45 +0000 (20:57 -0500)
committerTimo Heister <timo.heister@gmail.com>
Wed, 4 Mar 2020 15:54:01 +0000 (10:54 -0500)
source/distributed/grid_refinement.cc

index 4eb262fab715002c599e842cec8b263703d7eaf7..e5aeeb0b21b585eade2d4a8b9a430e25d7850a13 100644 (file)
@@ -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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.