Commit 8610fc15 by Christophe Geuzaine

tentative compile fix for petsc 3.9

parent fa814737
Pipeline #1634 passed with stage
in 24 minutes 39 seconds
......@@ -71,7 +71,7 @@ static void _try(int ierr)
static int SolverInitialized = 0;
#if ((PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 7)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 7))
#define PetscTruth PetscBool
#define PetscOptionsGetTruth(A, B, C, D) PetscOptionsGetBool(A, NULL, B, C, D)
#define PetscOptionsInsertFile(A, B, C) PetscOptionsInsertFile(A, NULL, B, C)
......@@ -186,7 +186,7 @@ void _fillseq(Vec &V, Vec &Vseq)
VecScatterEnd(ctx, V, Vseq, INSERT_VALUES, SCATTER_FORWARD);
#endif
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
VecScatterDestroy(&ctx);
#else
VecScatterDestroy(ctx);
......@@ -269,7 +269,7 @@ void LinAlg_CreateMatrix(gMatrix *M, gSolver *Solver, int n, int m)
void LinAlg_DestroySolver(gSolver *Solver)
{
for(int i = 0; i < 10; i++){
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
if(Solver->ksp[i]) _try(KSPDestroy(&Solver->ksp[i]));
if(Solver->snes[i]) _try(SNESDestroy(&Solver->snes[i]));
#else
......@@ -281,7 +281,7 @@ void LinAlg_DestroySolver(gSolver *Solver)
void LinAlg_DestroyVector(gVector *V)
{
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
_try(VecDestroy(&V->V));
if(V->haveSeq) _try(VecDestroy(&V->Vseq));
#else
......@@ -292,7 +292,7 @@ void LinAlg_DestroyVector(gVector *V)
void LinAlg_DestroyMatrix(gMatrix *M)
{
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
_try(MatDestroy(&M->M));
#else
_try(MatDestroy(M->M));
......@@ -436,7 +436,7 @@ void LinAlg_PrintVector(FILE *file, gVector *V, bool matlab,
_try(PetscViewerSetFormat(fd, PETSC_VIEWER_ASCII_MATLAB));
_try(PetscObjectSetName((PetscObject)V->V, varName));
_try(VecView(V->V, fd));
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
_try(PetscViewerDestroy(&fd));
#else
_try(PetscViewerDestroy(fd));
......@@ -480,7 +480,7 @@ void LinAlg_PrintMatrix(FILE *file, gMatrix *M, bool matlab,
_try(PetscViewerSetFormat(fd2, PETSC_VIEWER_DEFAULT));
_try(MatView(M->M, fd2));
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 2))
_try(PetscViewerDestroy(&fd));
_try(PetscViewerDestroy(&fd2));
#else
......@@ -1276,7 +1276,7 @@ static void _solve(gMatrix *A, gVector *B, gSolver *Solver, gVector *X,
if(!Solver->ksp[kspIndex]) {
_try(KSPCreate(MyComm, &Solver->ksp[kspIndex]));
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5))
_try(KSPSetOperators(Solver->ksp[kspIndex], A->M, A->M));
#else
_try(KSPSetOperators(Solver->ksp[kspIndex], A->M, A->M, DIFFERENT_NONZERO_PATTERN));
......@@ -1289,7 +1289,7 @@ static void _solve(gMatrix *A, gVector *B, gSolver *Solver, gVector *X,
// native PETSc LU)
_try(KSPSetType(Solver->ksp[kspIndex], "preonly"));
_try(PCSetType(pc, PCLU));
#if (PETSC_VERSION_RELEASE == 0)
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 9))
_try(PCFactorSetMatSolverType(pc, "mumps"));
#elif (PETSC_VERSION_MAJOR > 2) && defined(PETSC_HAVE_MUMPS)
_try(PCFactorSetMatSolverPackage(pc, "mumps"));
......@@ -1326,7 +1326,7 @@ static void _solve(gMatrix *A, gVector *B, gSolver *Solver, gVector *X,
_try(PCGetType(pc, &pctype));
#endif
#if (PETSC_VERSION_RELEASE == 0)
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 9))
MatSolverType stype;
_try(PCFactorGetMatSolverType(pc, &stype));
#elif (PETSC_VERSION_MAJOR > 2)
......@@ -1339,7 +1339,7 @@ static void _solve(gMatrix *A, gVector *B, gSolver *Solver, gVector *X,
}
}
else if(precond){
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5))
_try(KSPSetReusePreconditioner(Solver->ksp[kspIndex], PETSC_FALSE));
_try(KSPSetOperators(Solver->ksp[kspIndex], A->M, A->M));
#else
......@@ -1347,7 +1347,7 @@ static void _solve(gMatrix *A, gVector *B, gSolver *Solver, gVector *X,
#endif
}
else{
#if (PETSC_VERSION_RELEASE == 0 || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5)))
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 5))
_try(KSPSetReusePreconditioner(Solver->ksp[kspIndex], PETSC_TRUE));
#endif
}
......@@ -1535,7 +1535,7 @@ static void _solveNL(gMatrix *A, gVector *B, gMatrix *J, gVector *R, gSolver *So
_try(KSPGetPC(ksp, &pc));
_try(KSPSetType(ksp, "preonly"));
_try(PCSetType(pc, PCLU));
#if (PETSC_VERSION_RELEASE == 0)
#if (PETSC_VERSION_RELEASE == 0) || ((PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR >= 9))
_try(PCFactorSetMatSolverType(pc, "mumps"));
#elif (PETSC_VERSION_MAJOR > 2) && defined(PETSC_HAVE_MUMPS)
_try(PCFactorSetMatSolverPackage(pc, "mumps"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment