From 27f17ea07f3602d16bb5232f2597876bb83ae946 Mon Sep 17 00:00:00 2001
From: heister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Date: Wed, 5 Jun 2013 23:34:20 +0000
Subject: [PATCH] fix bug with PETSc SparseMatrix with no local entries

git-svn-id: https://svn.dealii.org/branches/branch_unify_linear_algebra@29776 0785d39b-7218-0410-832d-ea1e28bc413d
---
 .../source/lac/petsc_parallel_sparse_matrix.cc   | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc
index da6b5f1953..cc3279d79a 100644
--- a/deal.II/source/lac/petsc_parallel_sparse_matrix.cc
+++ b/deal.II/source/lac/petsc_parallel_sparse_matrix.cc
@@ -386,7 +386,9 @@ namespace PETScWrappers
             // read the documentation of this
             // class.
             //if (preset_nonzero_locations == true)
+            if (local_rows.n_elements()>0)
               {
+                Assert(local_columns.n_elements()>0, ExcInternalError());
                 // MatMPIAIJSetPreallocationCSR
                 // can be used to allocate the sparsity
                 // pattern of a matrix
@@ -443,8 +445,20 @@ namespace PETScWrappers
                                               &rowstart_in_window[0],
                                               &colnums_in_window[0],
                                               0);
-                compress ();
+              }
+            else
+              {
+                PetscInt i=0;
+                MatMPIAIJSetPreallocationCSR (matrix,
+                                              &i,
+                                              &i,
+                                              0);
+
+
+              }
+            compress (dealii::VectorOperation::insert);
 
+            {
 
                 // Tell PETSc that we are not
                 // planning on adding new entries
-- 
2.39.5