From: Wolfgang Bangerth Date: Thu, 5 Oct 2023 21:01:30 +0000 (-0600) Subject: Add another assertion. X-Git-Tag: relicensing~428^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16102%2Fhead;p=dealii.git Add another assertion. --- 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;