]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Apply fix also for PETScWrappers::SparseMatrix in the same way it was done for MPI...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Feb 2011 10:00:23 +0000 (10:00 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Feb 2011 10:00:23 +0000 (10:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@23424 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/lac/petsc_sparse_matrix.cc

index 13faa70e1848f0d40b48e7fdf93080e0d1e1dd95..5b06c323f4e4491d27aaba8d96412d451b662eb2 100644 (file)
@@ -266,9 +266,9 @@ namespace PETScWrappers
                                         // 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)
+                                        // in debug mode.
           int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
 #ifdef DEBUG
          ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR);
          AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -277,7 +277,6 @@ namespace PETScWrappers
          AssertThrow (ierr == 0, ExcPETScError(ierr));
 #endif  
 #else
-          int ierr;
 #ifdef DEBUG
          ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE);
          AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -286,6 +285,22 @@ namespace PETScWrappers
          AssertThrow (ierr == 0, ExcPETScError(ierr));
 #endif
 #endif
+
+                                          // Tell PETSc to keep the
+                                          // SparsityPattern entries even if
+                                          // we delete a row with
+                                          // clear_rows() which calls
+                                          // MatZeroRows(). Otherwise one can
+                                          // not write into that row
+                                          // afterwards.
+#if DEAL_II_PETSC_VERSION_LT(3,1,0)
+         ierr = MatSetOption (matrix, MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+         ierr = MatSetOption (matrix, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
+         AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif
+
       }
   }
 

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.