From 1c5fd2143654d6a211ae5a1665bd85fae852afb6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 15 Jul 2021 16:27:12 -0600 Subject: [PATCH] Add a couple of exceptions that ensure we don't accidentally run out of indices. --- source/dofs/dof_handler_policy.cc | 34 +++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index f4315a2477..8c6118284a 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -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::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::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); } -- 2.39.5