]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add an assertion. 15049/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Apr 2023 19:06:03 +0000 (13:06 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Apr 2023 19:06:03 +0000 (13:06 -0600)
include/deal.II/lac/affine_constraints.templates.h

index f1d018c4900b02fbd67d50a7e5ef703d5b9d0169..6bb755bc739c37861ec34ebb59d55cab5fc3e36d 100644 (file)
@@ -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;
           }
       }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.