From b1fa8f4448d01e1e586e9c6d6d077d898b755437 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 7 Apr 2023 13:06:03 -0600 Subject: [PATCH] Add an assertion. --- include/deal.II/lac/affine_constraints.templates.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index f1d018c490..6bb755bc73 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -3345,10 +3345,21 @@ namespace internal { while (matrix_values->column() < column) ++matrix_values; + + // Ensure that we haven't walked off the end of the row and + // accidentally found the column in a later row. This should + // not have happened since we believed we know that we enter + // entries sorted by column, and that all columns are represented + // in the current matrix row. But it's worth checking. + Assert(matrix_values->row() == row, ExcInternalError()); + + // Then also assert that the column index actually exists. Assert(matrix_values->column() == column, typename SparseMatrix< typename SparseMatrixIterator::MatrixType::value_type>:: ExcInvalidIndex(row, column)); + + // Now so convinced, let us add the relevant value: matrix_values->value() += value; } } -- 2.39.5