From d22bfd0f9b5ac6ceea1012f67da907d7d70b40a7 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 5 Oct 2023 15:01:30 -0600 Subject: [PATCH] Add another assertion. --- .../lac/affine_constraints.templates.h | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index c00d803f46..00a912d874 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -2671,9 +2671,23 @@ AffineConstraints::distribute(VectorType &vec) const // pass as arguments... #ifdef DEBUG if (needed_elements_for_distribute != IndexSet()) - for (const auto i : vec_owned_elements) - Assert(needed_elements_for_distribute.is_element(i), - ExcInternalError()); + { + Assert(vec_owned_elements.size() == + needed_elements_for_distribute.size(), + ExcMessage("You have previously initialized this " + "AffineConstraints object with an index set " + "that stated that vectors have size " + + std::to_string(locally_owned_dofs.size()) + + " entries, but you are now calling " + "AffineConstraints::distribute() with a vector " + "of size " + + std::to_string(vec_owned_elements.size()) + + ".")); + + for (const auto i : vec_owned_elements) + Assert(needed_elements_for_distribute.is_element(i), + ExcInternalError()); + } #endif VectorType ghosted_vector; -- 2.39.5