| 1 |
diff --git a/dolfin/la/PETScKrylovSolver.cpp b/dolfin/la/PETScKrylovSolver.cpp |
| 2 |
index e729093..afbde0f 100644 |
| 3 |
--- a/dolfin/la/PETScKrylovSolver.cpp |
| 4 |
+++ b/dolfin/la/PETScKrylovSolver.cpp |
| 5 |
@@ -496,10 +496,17 @@ void PETScKrylovSolver::monitor(bool monitor_convergence) |
| 6 |
PetscViewerFormat format = PETSC_VIEWER_DEFAULT; |
| 7 |
PetscViewerAndFormat *vf; |
| 8 |
PetscViewerAndFormatCreate(viewer,format,&vf); |
| 9 |
+ #if PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 15 |
| 10 |
+ ierr = KSPMonitorSet(_ksp, |
| 11 |
+ (PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidual, |
| 12 |
+ vf, |
| 13 |
+ (PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 14 |
+ #else |
| 15 |
ierr = KSPMonitorSet(_ksp, |
| 16 |
(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidualNorm, |
| 17 |
vf, |
| 18 |
(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 19 |
+ #endif |
| 20 |
if (ierr != 0) petsc_error(ierr, __FILE__, "KSPMonitorSet"); |
| 21 |
} |
| 22 |
else |
| 23 |
diff --git a/dolfin/nls/PETScSNESSolver.cpp b/dolfin/nls/PETScSNESSolver.cpp |
| 24 |
index 71bca08..9761f74 100644 |
| 25 |
--- a/dolfin/nls/PETScSNESSolver.cpp |
| 26 |
+++ b/dolfin/nls/PETScSNESSolver.cpp |
| 27 |
@@ -516,10 +516,17 @@ void PETScSNESSolver::set_linear_solver_parameters() |
| 28 |
PetscViewerAndFormat *vf; |
| 29 |
ierr = PetscViewerAndFormatCreate(viewer,format,&vf); |
| 30 |
if (ierr != 0) petsc_error(ierr, __FILE__, "PetscViewerAndFormatCreate"); |
| 31 |
+ #if PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 15 |
| 32 |
+ ierr = KSPMonitorSet(ksp, |
| 33 |
+ (PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidual, |
| 34 |
+ vf, |
| 35 |
+ (PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 36 |
+ #else |
| 37 |
ierr = KSPMonitorSet(ksp, |
| 38 |
(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidualNorm, |
| 39 |
vf, |
| 40 |
(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 41 |
+ #endif |
| 42 |
if (ierr != 0) petsc_error(ierr, __FILE__, "KSPMonitorSet"); |
| 43 |
} |
| 44 |
|
| 45 |
diff --git a/dolfin/nls/PETScTAOSolver.cpp b/dolfin/nls/PETScTAOSolver.cpp |
| 46 |
index cebb0de..96ecf55 100644 |
| 47 |
--- a/dolfin/nls/PETScTAOSolver.cpp |
| 48 |
+++ b/dolfin/nls/PETScTAOSolver.cpp |
| 49 |
@@ -576,10 +576,17 @@ void PETScTAOSolver::set_ksp_options() |
| 50 |
PetscViewerFormat format = PETSC_VIEWER_DEFAULT; |
| 51 |
PetscViewerAndFormat *vf; |
| 52 |
ierr = PetscViewerAndFormatCreate(viewer,format,&vf); |
| 53 |
+ #if PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 15 |
| 54 |
+ ierr = KSPMonitorSet(ksp, |
| 55 |
+ (PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidual, |
| 56 |
+ vf, |
| 57 |
+ (PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 58 |
+ #else |
| 59 |
ierr = KSPMonitorSet(ksp, |
| 60 |
(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidualNorm, |
| 61 |
vf, |
| 62 |
(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 63 |
+ #endif |
| 64 |
if (ierr != 0) petsc_error(ierr, __FILE__, "KSPMonitorSet"); |
| 65 |
} |
| 66 |
} |
| 67 |
diff --git a/dolfin/nls/TAOLinearBoundSolver.cpp b/dolfin/nls/TAOLinearBoundSolver.cpp |
| 68 |
index 0ca775c..78fa1e7 100644 |
| 69 |
--- a/dolfin/nls/TAOLinearBoundSolver.cpp |
| 70 |
+++ b/dolfin/nls/TAOLinearBoundSolver.cpp |
| 71 |
@@ -413,8 +413,13 @@ void TAOLinearBoundSolver::set_ksp_options() |
| 72 |
PetscViewerFormat format = PETSC_VIEWER_DEFAULT; |
| 73 |
PetscViewerAndFormat *vf; |
| 74 |
ierr = PetscViewerAndFormatCreate(viewer,format,&vf); |
| 75 |
+ #if PETSC_VERSION_MAJOR == 3 && PETSC_VERSION_MINOR >= 15 |
| 76 |
+ ierr = KSPMonitorSet(ksp, (PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidual, |
| 77 |
+ vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 78 |
+ #else |
| 79 |
ierr = KSPMonitorSet(ksp, (PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*)) KSPMonitorTrueResidualNorm, |
| 80 |
vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy); |
| 81 |
+ #endif |
| 82 |
if (ierr != 0) petsc_error(ierr, __FILE__, "KSPMonitorSet"); |
| 83 |
} |
| 84 |
} |