From: Wolfgang Bangerth Date: Fri, 7 Apr 2023 19:06:03 +0000 (-0600) Subject: Add an assertion. X-Git-Tag: v9.5.0-rc1~360^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15049%2Fhead;p=dealii.git Add an assertion. --- 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; } }