From: Wolfgang Bangerth Date: Thu, 15 Jul 2021 22:27:12 +0000 (-0600) Subject: Add a couple of exceptions that ensure we don't accidentally run out of indices. X-Git-Tag: v9.4.0-rc1~1142^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12572%2Fhead;p=dealii.git Add a couple of exceptions that ensure we don't accidentally run out of indices. --- 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); }