From 92bf9e7e8745add0b2cbc351d43ca0721760acd5 Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 24 Aug 2011 18:30:31 +0000 Subject: [PATCH] additional sanity checks in ConstraintMatrix in debug mode. git-svn-id: https://svn.dealii.org/trunk@24181 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/lac/constraint_matrix.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deal.II/include/deal.II/lac/constraint_matrix.h b/deal.II/include/deal.II/lac/constraint_matrix.h index 14140084e7..3de3362880 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.h @@ -365,6 +365,8 @@ class ConstraintMatrix : public Subscriptor * constraint line i, according * to the discussion in the general * class description. + * Note: the line needs to be added with + * one of the add_line() calls first. */ void set_inhomogeneity (const unsigned int line, const double value); @@ -1857,7 +1859,12 @@ void ConstraintMatrix::set_inhomogeneity (const unsigned int line, const double value) { - ConstraintLine* line_ptr = &lines[lines_cache[calculate_line_index(line)]]; + const unsigned int line_index = calculate_line_index(line); + Assert( line_index < lines_cache.size() && + lines_cache[line_index] != numbers::invalid_unsigned_int, + ExcMessage("call add_line() before calling set_inhomogeneity()")); + Assert(lines_cache[line_index] < lines.size(), ExcInternalError()); + ConstraintLine* line_ptr = &lines[lines_cache[line_index]]; line_ptr->inhomogeneity = value; } -- 2.39.5