From b19c99d682911c4dc91452ad12f6acea5cc9e195 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Thu, 31 Mar 2011 10:34:38 +0000
Subject: [PATCH] Added switch between zero and non zero start vector for
 PETSc.

---
 AMDiS/libtool                          |  6 +++---
 AMDiS/src/parallel/PetscProblemStat.cc | 19 +++++++++++--------
 AMDiS/src/parallel/PetscProblemStat.h  |  9 +++++++--
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/AMDiS/libtool b/AMDiS/libtool
index 21443861..a502627c 100755
--- a/AMDiS/libtool
+++ b/AMDiS/libtool
@@ -44,7 +44,7 @@ available_tags=" CXX F77"
 
 # ### BEGIN LIBTOOL CONFIG
 
-# Libtool was configured on host deimos101:
+# Libtool was configured on host p1q024:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
 # End:
 # ### BEGIN LIBTOOL TAG CONFIG: CXX
 
-# Libtool was configured on host deimos101:
+# Libtool was configured on host p1q024:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
@@ -7065,7 +7065,7 @@ include_expsyms=""
 
 # ### BEGIN LIBTOOL TAG CONFIG: F77
 
-# Libtool was configured on host deimos101:
+# Libtool was configured on host p1q024:
 
 # Shell to use when invoking shell scripts.
 SHELL="/bin/sh"
diff --git a/AMDiS/src/parallel/PetscProblemStat.cc b/AMDiS/src/parallel/PetscProblemStat.cc
index 0d8a279f..ea6b5437 100644
--- a/AMDiS/src/parallel/PetscProblemStat.cc
+++ b/AMDiS/src/parallel/PetscProblemStat.cc
@@ -587,14 +587,16 @@ namespace AMDiS {
     FUNCNAME("PetscProblemStat::solvePetscMatrix()");
 
     // === Set old solution to be initiual guess for PETSc solver. ===
-    
-    VecSet(petscSolVec, 0.0);
-
-    for (int i = 0; i < nComponents; i++)
-      setDofVector(petscSolVec, vec.getDOFVector(i), nComponents, i, true);
 
-    VecAssemblyBegin(petscSolVec);
-    VecAssemblyEnd(petscSolVec);
+    if (!zeroStartVector) {
+      VecSet(petscSolVec, 0.0);
+      
+      for (int i = 0; i < nComponents; i++)
+	setDofVector(petscSolVec, vec.getDOFVector(i), nComponents, i, true);
+      
+      VecAssemblyBegin(petscSolVec);
+      VecAssemblyEnd(petscSolVec);
+    }
 
 
     // === Init PETSc solver. ===
@@ -607,7 +609,8 @@ namespace AMDiS {
     delete petscSolver;
 
     // Do not delete the solution vector, use it for the initial guess.
-    KSPSetInitialGuessNonzero(solver, PETSC_TRUE);
+    if (!zeroStartVector)
+      KSPSetInitialGuessNonzero(solver, PETSC_TRUE);
    
     // === Run PETSc. ===
 
diff --git a/AMDiS/src/parallel/PetscProblemStat.h b/AMDiS/src/parallel/PetscProblemStat.h
index d2163c55..77278bec 100644
--- a/AMDiS/src/parallel/PetscProblemStat.h
+++ b/AMDiS/src/parallel/PetscProblemStat.h
@@ -44,8 +44,11 @@ namespace AMDiS {
       : ParallelProblemStatBase(nameStr, problemIteration),
 	d_nnz(NULL),
 	o_nnz(NULL),
-	lastMeshNnz(0)
-    {}
+	lastMeshNnz(0),
+	zeroStartVector(false)
+    {
+      GET_PARAMETER(0, "parallel->use zero start vector", "%d", &zeroStartVector);
+    }
 
     ~PetscProblemStat()
     {}
@@ -97,6 +100,8 @@ namespace AMDiS {
      * therefore also the assembled matrix structure.
      */
     int lastMeshNnz;
+
+    bool zeroStartVector;
   };
 
   typedef PetscProblemStat ParallelProblemStat;
-- 
GitLab