]> https://gitweb.dealii.org/ - dealii.git/commitdiff
PETScWrappers::MatrixBase: fix an assertion.
authorDavid Wells <drwells@email.unc.edu>
Sun, 11 Aug 2024 21:24:31 +0000 (15:24 -0600)
committerDavid Wells <drwells@email.unc.edu>
Mon, 12 Aug 2024 04:19:47 +0000 (22:19 -0600)
source/lac/petsc_matrix_base.cc

index 17ca8ae36610b0bde0eb48e295648d52818456e4..ada3a2220e47a972f39c76162058e1fd39278806 100644 (file)
@@ -166,11 +166,8 @@ namespace PETScWrappers
 
     // now set all the entries of these rows to zero
 #  ifdef DEBUG
-    for (size_type i = 0; i < rows.size(); ++i)
-      {
-        const auto row = static_cast<PetscInt>(rows[i]);
-        AssertIntegerConversion(row, rows[i]);
-      }
+    for (const auto &row : rows)
+      AssertIntegerConversion(static_cast<PetscInt>(row), row);
 #  endif
     const std::vector<PetscInt> petsc_rows(rows.begin(), rows.end());
 
@@ -201,11 +198,8 @@ namespace PETScWrappers
 
     // now set all the entries of these rows to zero
 #  ifdef DEBUG
-    for (size_type i = 0; i < rows.size(); ++i)
-      {
-        const auto row = static_cast<PetscInt>(rows[i]);
-        AssertIntegerConversion(row, rows[i]);
-      }
+    for (const auto &row : rows)
+      AssertIntegerConversion(static_cast<PetscInt>(row), row);
 #  endif
     const std::vector<PetscInt> petsc_rows(rows.begin(), rows.end());
 
@@ -410,7 +404,7 @@ namespace PETScWrappers
     // something that is unreasonable. there should simply be a way in PETSc to
     // query the number of entries in a row bypassing the call to compress(),
     // but I can't find one
-    Assert(row < m(), ExcInternalError());
+    AssertIndexRange(row, m());
 
     // get a representation of the present
     // row

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.