]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
PETSc::SparseMatrix now gives an error in debug mode when you try to add additional...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Nov 2010 13:07:07 +0000 (13:07 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Nov 2010 13:07:07 +0000 (13:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@22666 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/lac/petsc_sparse_matrix.cc

index afe6050a561ff1fcd0336ce3ef537e0213723459..13faa70e1848f0d40b48e7fdf93080e0d1e1dd95 100644 (file)
@@ -261,17 +261,31 @@ namespace PETScWrappers
                           &row_values[0], INSERT_VALUES);
           }
         compress ();
-                                       // In the end, tell the matrix that
-                                       // it should not expect any new
-                                       // entries.
+
+
+                                        // Tell PETSc that we are not
+                                        // planning on adding new entries
+                                        // to the matrix. Generate errors
+                                        // in debugmode.
 #if DEAL_II_PETSC_VERSION_LT(3,0,0)
-       const int ierr =
-         MatSetOption (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
+          int ierr;
+#ifdef DEBUG
+         ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+         ierr = MatSetOption (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif  
 #else
-       const int ierr =
-         MatSetOption (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
+          int ierr;
+#ifdef DEBUG
+         ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+         ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif
 #endif
-       AssertThrow (ierr == 0, ExcPETScError(ierr));
       }
   }
 

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.