From 20c1e7f3d304b50be8c337528d98456e5f06dbbc Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Fri, 6 May 2011 11:20:35 +0000
Subject: [PATCH] Change to new petsc-dev with new signature of all ...Destroy
 functions.

---
 AMDiS/src/parallel/PetscSolverFeti.cc         | 84 +++++++++----------
 AMDiS/src/parallel/PetscSolverGlobalMatrix.cc |  8 ++
 AMDiS/src/parallel/PetscSolverSchur.cc        | 18 ++--
 3 files changed, 59 insertions(+), 51 deletions(-)

diff --git a/AMDiS/src/parallel/PetscSolverFeti.cc b/AMDiS/src/parallel/PetscSolverFeti.cc
index 39a36c12..ce106fcc 100644
--- a/AMDiS/src/parallel/PetscSolverFeti.cc
+++ b/AMDiS/src/parallel/PetscSolverFeti.cc
@@ -550,11 +550,11 @@ namespace AMDiS {
     petscSchurPrimalData.mat_b_primal = PETSC_NULL;
     petscSchurPrimalData.ksp_b = PETSC_NULL;
 
-    VecDestroy(petscSchurPrimalData.tmp_vec_b);
-    VecDestroy(petscSchurPrimalData.tmp_vec_primal);
+    VecDestroy(&petscSchurPrimalData.tmp_vec_b);
+    VecDestroy(&petscSchurPrimalData.tmp_vec_primal);
 
-    MatDestroy(mat_schur_primal);
-    KSPDestroy(ksp_schur_primal);
+    MatDestroy(&mat_schur_primal);
+    KSPDestroy(&ksp_schur_primal);
   }
 
 
@@ -636,17 +636,17 @@ namespace AMDiS {
     petscFetiData.ksp_b = PETSC_NULL;
     petscFetiData.ksp_schur_primal = PETSC_NULL;
 
-    VecDestroy(petscFetiData.tmp_vec_b);
-    VecDestroy(petscFetiData.tmp_vec_primal);
-    VecDestroy(petscFetiData.tmp_vec_lagrange);
+    VecDestroy(&petscFetiData.tmp_vec_b);
+    VecDestroy(&petscFetiData.tmp_vec_primal);
+    VecDestroy(&petscFetiData.tmp_vec_lagrange);
 
-    MatDestroy(mat_feti);
-    KSPDestroy(ksp_feti);
+    MatDestroy(&mat_feti);
+    KSPDestroy(&ksp_feti);
 
 
     // === Destroy FETI-DP Dirichlet preconditioner object. ===
 
-    KSPDestroy(ksp_interior);
+    KSPDestroy(&ksp_interior);
 
     petscFetiPreconData.mat_lagrange_scaled = NULL;
     petscFetiPreconData.mat_interior_interior = NULL;
@@ -655,11 +655,11 @@ namespace AMDiS {
     petscFetiPreconData.mat_bound_interior = NULL;
     petscFetiPreconData.ksp_interior = NULL;
 
-    VecDestroy(petscFetiPreconData.tmp_vec_b);
-    VecDestroy(petscFetiPreconData.tmp_vec_bound0);
-    VecDestroy(petscFetiPreconData.tmp_vec_bound1);
-    VecDestroy(petscFetiPreconData.tmp_vec_interior);
-    MatDestroy(mat_lagrange_scaled);
+    VecDestroy(&petscFetiPreconData.tmp_vec_b);
+    VecDestroy(&petscFetiPreconData.tmp_vec_bound0);
+    VecDestroy(&petscFetiPreconData.tmp_vec_bound1);
+    VecDestroy(&petscFetiPreconData.tmp_vec_interior);
+    MatDestroy(&mat_lagrange_scaled);
   }
 
 
@@ -716,9 +716,9 @@ namespace AMDiS {
     VecScatterEnd(primalScatter, vec_sol_primal, local_sol_primal, 
 		  INSERT_VALUES, SCATTER_FORWARD);
 
-    ISDestroy(globalIs);
-    ISDestroy(localIs);    
-    VecScatterDestroy(primalScatter);    
+    ISDestroy(&globalIs);
+    ISDestroy(&localIs);    
+    VecScatterDestroy(&primalScatter);    
 
     PetscScalar *localSolPrimal;
     VecGetArray(local_sol_primal, &localSolPrimal);
@@ -747,7 +747,7 @@ namespace AMDiS {
 
     VecRestoreArray(vec_sol_b, &localSolB);
     VecRestoreArray(local_sol_primal, &localSolPrimal);
-    VecDestroy(local_sol_primal);
+    VecDestroy(&local_sol_primal);
   }
 
 
@@ -1213,12 +1213,12 @@ namespace AMDiS {
 
     recoverSolution(u_b, u_primal, vec);
 
-    VecDestroy(u_b);
-    VecDestroy(u_primal);
-    VecDestroy(b);
-    VecDestroy(f);
+    VecDestroy(&u_b);
+    VecDestroy(&u_primal);
+    VecDestroy(&b);
+    VecDestroy(&f);
 
-    KSPDestroy(ksp);
+    KSPDestroy(&ksp);
   }
 
 
@@ -1311,24 +1311,24 @@ namespace AMDiS {
 
     // === Destroy all data structures. ===
     
-    VecDestroy(vec_rhs);
-    VecDestroy(tmp_b0);
-    VecDestroy(tmp_b1);
-    VecDestroy(tmp_lagrange0);
-    VecDestroy(tmp_primal0);
-    VecDestroy(tmp_primal1);
+    VecDestroy(&vec_rhs);
+    VecDestroy(&tmp_b0);
+    VecDestroy(&tmp_b1);
+    VecDestroy(&tmp_lagrange0);
+    VecDestroy(&tmp_primal0);
+    VecDestroy(&tmp_primal1);
 	    
 
-    KSPDestroy(ksp_b);
+    KSPDestroy(&ksp_b);
 
-    MatDestroy(mat_b_b);
-    MatDestroy(mat_primal_primal);
-    MatDestroy(mat_b_primal);
-    MatDestroy(mat_primal_b);
-    MatDestroy(mat_lagrange);
+    MatDestroy(&mat_b_b);
+    MatDestroy(&mat_primal_primal);
+    MatDestroy(&mat_b_primal);
+    MatDestroy(&mat_primal_b);
+    MatDestroy(&mat_lagrange);
 
-    VecDestroy(f_b);
-    VecDestroy(f_primal);
+    VecDestroy(&f_b);
+    VecDestroy(&f_primal);
 
     destroySchurPrimalKsp();
 
@@ -1337,10 +1337,10 @@ namespace AMDiS {
     
     // === Destroy preconditioner data structures. ===
 
-    MatDestroy(mat_interior_interior);
-    MatDestroy(mat_bound_bound);
-    MatDestroy(mat_interior_bound);
-    MatDestroy(mat_bound_interior);
+    MatDestroy(&mat_interior_interior);
+    MatDestroy(&mat_bound_bound);
+    MatDestroy(&mat_interior_bound);
+    MatDestroy(&mat_bound_interior);
   }
 
 
diff --git a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
index cc79543d..5eff17d9 100644
--- a/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
+++ b/AMDiS/src/parallel/PetscSolverGlobalMatrix.cc
@@ -179,11 +179,19 @@ namespace AMDiS {
 
     // === Destroy PETSc's variables. ===
 
+#ifdef HAVE_PETSC_DEV 
+    MatDestroy(&petscMatrix);
+    VecDestroy(&petscRhsVec);
+    VecDestroy(&petscSolVec);
+    VecDestroy(&petscTmpVec);
+    KSPDestroy(&solver);
+#else
     MatDestroy(petscMatrix);
     VecDestroy(petscRhsVec);
     VecDestroy(petscSolVec);
     VecDestroy(petscTmpVec);
     KSPDestroy(solver);
+#endif
   }
 
 
diff --git a/AMDiS/src/parallel/PetscSolverSchur.cc b/AMDiS/src/parallel/PetscSolverSchur.cc
index bee57fdb..a4c5761e 100644
--- a/AMDiS/src/parallel/PetscSolverSchur.cc
+++ b/AMDiS/src/parallel/PetscSolverSchur.cc
@@ -327,17 +327,17 @@ namespace AMDiS {
 
     // === Destroy PETSC's variables. ===
 
-    VecDestroy(petscRhsVec);
-    VecDestroy(petscSolVec);
-    VecDestroy(petscTmpVec);
+    VecDestroy(&petscRhsVec);
+    VecDestroy(&petscSolVec);
+    VecDestroy(&petscTmpVec);
 
-    MatDestroy(matA11);
-    MatDestroy(matA12);
-    MatDestroy(matA21);
-    MatDestroy(matA22);
-    MatDestroy(petscMatrix);
+    MatDestroy(&matA11);
+    MatDestroy(&matA12);
+    MatDestroy(&matA21);
+    MatDestroy(&matA22);
+    MatDestroy(&petscMatrix);
 
-    KSPDestroy(solver);
+    KSPDestroy(&solver);
   }
   
 
-- 
GitLab