From bd4887530154908713a349bb963749babf9247f1 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Mon, 20 Feb 2012 13:25:41 +0000
Subject: [PATCH] Possibility to remove null space of rhs vectors in parallel
 computations.

---
 AMDiS/src/parallel/PetscSolverGlobalMatrix.cc | 7 +++++++
 AMDiS/src/parallel/PetscSolverGlobalMatrix.h  | 8 +++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
index cd21ab43..5c9562aa 100644
--- a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
+++ b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
@@ -151,6 +151,13 @@ namespace AMDiS {
 
     VecAssemblyBegin(petscRhsVec);
     VecAssemblyEnd(petscRhsVec);
+
+    if (removeRhsNullSpace) {
+      MatNullSpace sp;
+      MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, PETSC_NULL, &sp);
+      MatNullSpaceRemove(sp, petscRhsVec, PETSC_NULL);
+      MatNullSpaceDestroy(&sp);
+    }
   }
 
 
diff --git a/AMDiS/src/parallel/PetscSolverGlobalMatrix.h b/AMDiS/src/parallel/PetscSolverGlobalMatrix.h
index e53add03..4e60a933 100644
--- a/AMDiS/src/parallel/PetscSolverGlobalMatrix.h
+++ b/AMDiS/src/parallel/PetscSolverGlobalMatrix.h
@@ -88,11 +88,14 @@ namespace AMDiS {
 	o_nnz(NULL),
 	lastMeshNnz(0),
 	zeroStartVector(false),
-	alwaysCreateNnzStructure(false)
+	alwaysCreateNnzStructure(false),
+	removeRhsNullSpace(false)
     {
       Parameters::get("parallel->use zero start vector", zeroStartVector);
       Parameters::get("parallel->always create nnz structure", 
 		      alwaysCreateNnzStructure);
+      Parameters::get("parallel->remove rhs null space", 
+		      removeRhsNullSpace);
     }
 
     void fillPetscMatrix(Matrix<DOFMatrix*> *mat);
@@ -141,6 +144,9 @@ namespace AMDiS {
     /// Mapping from global DOF indices to global matrix indices under 
     /// consideration of possibly multiple components.
     DofToMatIndex dofToMatIndex;
+
+    /// If true, the constant null space is projected out of the RHS vector.
+    bool removeRhsNullSpace;
   };
 
 
-- 
GitLab