From: heister Date: Wed, 10 Nov 2010 13:07:07 +0000 (+0000) Subject: PETSc::SparseMatrix now gives an error in debug mode when you try to add additional... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f2c6bb412a759cd7d90a1cc19e4036efcec9e97;p=dealii-svn.git PETSc::SparseMatrix now gives an error in debug mode when you try to add additional non-zero entries. git-svn-id: https://svn.dealii.org/trunk@22666 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/lac/petsc_sparse_matrix.cc b/deal.II/source/lac/petsc_sparse_matrix.cc index afe6050a56..13faa70e18 100644 --- a/deal.II/source/lac/petsc_sparse_matrix.cc +++ b/deal.II/source/lac/petsc_sparse_matrix.cc @@ -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)); } }