From f0ae40e820678d397ba95803905754f399f67e39 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 17 Sep 2011 10:27:37 +0000
Subject: [PATCH] support for petsc-dev

---
 Solver/eigenSolver.cpp       | 11 +++++++++++
 Solver/linearSystemPETSc.cpp |  6 ++++++
 Solver/linearSystemPETSc.hpp | 20 ++++++++++++++++++--
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/Solver/eigenSolver.cpp b/Solver/eigenSolver.cpp
index d2585ebcf9..f594831c0b 100644
--- a/Solver/eigenSolver.cpp
+++ b/Solver/eigenSolver.cpp
@@ -105,8 +105,10 @@ bool eigenSolver::solve(int numEigenValues, std::string which)
     Msg::Error("SLEPc diverged after %d iterations", its);
   else if(reason == EPS_DIVERGED_BREAKDOWN)
     Msg::Error("SLEPc generic breakdown in method");
+#if !(PETSC_VERSION_RELEASE == 0) // petsc-dev
   else if(reason == EPS_DIVERGED_NONSYMMETRIC)
     Msg::Error("The operator is nonsymmetric");
+#endif
 
   // get number of converged approximate eigenpairs
   PetscInt nconv;
@@ -152,11 +154,20 @@ bool eigenSolver::solve(int numEigenValues, std::string which)
       }
        _eigenVectors.push_back(ev);
     }
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+    _try(VecDestroy(&xr));
+    _try(VecDestroy(&xi));
+#else
     _try(VecDestroy(xr));
     _try(VecDestroy(xi));
+#endif
   }
 
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+  _try(EPSDestroy(&eps));
+#else
   _try(EPSDestroy(eps));
+#endif
 
   if(reason == EPS_CONVERGED_TOL){
     Msg::Debug("SLEPc done");
diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp
index 520e0c13cd..809d532f9f 100644
--- a/Solver/linearSystemPETSc.cpp
+++ b/Solver/linearSystemPETSc.cpp
@@ -145,9 +145,15 @@ bool linearSystemPETScBlockDouble::isAllocated() const
 void linearSystemPETScBlockDouble::clear()
 {
   if(_isAllocated){
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+    MatDestroy(&_a);
+    VecDestroy(&_x);
+    VecDestroy(&_b);
+#else
     MatDestroy(_a);
     VecDestroy(_x);
     VecDestroy(_b);
+#endif
   }
   _isAllocated = false;
 }
diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp
index 67c35945ef..783b16142d 100644
--- a/Solver/linearSystemPETSc.hpp
+++ b/Solver/linearSystemPETSc.hpp
@@ -2,6 +2,12 @@
 #include <petsc.h>
 #include <petscksp.h>
 #include "linearSystemPETSc.h"
+
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+#define PetscTruth PetscBool
+#define PetscOptionsGetTruth PetscOptionsGetBool
+#endif
+
 static void  _try(int ierr)
 {
   CHKERRABORT(PETSC_COMM_WORLD, ierr);
@@ -39,8 +45,12 @@ template <class scalar>
 linearSystemPETSc<scalar>::~linearSystemPETSc()
 {
   clear();
-  if (_kspAllocated)
-    _try (KSPDestroy (_ksp));
+  if(_kspAllocated)
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+    _try(KSPDestroy(&_ksp));
+#else
+    _try(KSPDestroy(_ksp));
+#endif
 }
 
 template <class scalar>
@@ -141,9 +151,15 @@ template <class scalar>
 void linearSystemPETSc<scalar>::clear()
 {
   if(_isAllocated){
+#if (PETSC_VERSION_RELEASE == 0) // petsc-dev
+    _try(MatDestroy(&_a));
+    _try(VecDestroy(&_x));
+    _try(VecDestroy(&_b));
+#else
     _try(MatDestroy(_a));
     _try(VecDestroy(_x));
     _try(VecDestroy(_b));
+#endif
   }
   _isAllocated = false;
 }
-- 
GitLab