]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a couple of exceptions that ensure we don't accidentally run out of indices. 12572/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 15 Jul 2021 22:27:12 +0000 (16:27 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 15 Jul 2021 22:51:27 +0000 (16:51 -0600)
source/dofs/dof_handler_policy.cc

index f4315a247791247f657c95927f30499395a3756f..8c6118284ab5988ad381c5e0c57809123aacec06 100644 (file)
@@ -35,6 +35,7 @@
 #include <deal.II/grid/tria_iterator.h>
 
 #include <algorithm>
+#include <limits>
 #include <memory>
 #include <numeric>
 #include <set>
@@ -1720,7 +1721,22 @@ namespace internal
 
                   for (auto &dof_index : dof_indices)
                     if (dof_index == numbers::invalid_dof_index)
-                      dof_index = next_free_dof++;
+                      {
+                        dof_index = next_free_dof;
+
+                        Assert(
+                          next_free_dof !=
+                            std::numeric_limits<types::global_dof_index>::max(),
+                          ExcMessage(
+                            "You have reached the maximal number of degrees of "
+                            "freedom that can be stored in the chosen data type. "
+                            "In practice, this can only happen if you are using "
+                            "32-bit data types. You will have to re-compile "
+                            "deal.II with the `DEAL_II_WITH_64BIT_INDICES' "
+                            "flag set to `ON'."));
+                        ++next_free_dof;
+                      }
+
 
                   cell->set_dof_indices(dof_indices);
                 }
@@ -1806,7 +1822,21 @@ namespace internal
 
                 for (auto &dof_index : dof_indices)
                   if (dof_index == numbers::invalid_dof_index)
-                    dof_index = next_free_dof++;
+                    {
+                      dof_index = next_free_dof;
+
+                      Assert(
+                        next_free_dof !=
+                          std::numeric_limits<types::global_dof_index>::max(),
+                        ExcMessage(
+                          "You have reached the maximal number of degrees of "
+                          "freedom that can be stored in the chosen data type. "
+                          "In practice, this can only happen if you are using "
+                          "32-bit data types. You will have to re-compile "
+                          "deal.II with the `DEAL_II_WITH_64BIT_INDICES' "
+                          "flag set to `ON'."));
+                      ++next_free_dof;
+                    }
 
                 cell->set_mg_dof_indices(dof_indices);
               }

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.