]> https://gitweb.dealii.org/ - dealii.git/commitdiff
use Utilities::needed_digits() in write_vtu_with_pvtu_record()
authorNiklas Fehn <fehn@lnm.mw.tum.de>
Fri, 18 Oct 2019 12:44:50 +0000 (14:44 +0200)
committerNiklas Fehn <fehn@lnm.mw.tum.de>
Fri, 18 Oct 2019 13:01:54 +0000 (15:01 +0200)
source/base/data_out_base.cc

index af277a330e7727a2bdd9b4e564f15e8962a6558c..666acafb9cf8f61054c8d068a820ec955d8c280f 100644 (file)
@@ -7560,8 +7560,11 @@ DataOutInterface<dim, spacedim>::write_vtu_with_pvtu_record(
   const unsigned int n_files_written =
     (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
 
+  AssertThrow(n_files_written >= 1, ExcMessage("Logical error."));
+  // the "-1" is needed since we use C++ style counting starting with 0, so
+  // writing 10 files means the filename runs from 0 to 9
   const unsigned int n_digits =
-    static_cast<int>(std::ceil(std::log10(std::fabs(n_files_written))));
+    Utilities::needed_digits(std::max(0, int(n_files_written) - 1));
 
   const unsigned int color = rank % n_files_written;
   const std::string  filename =

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.