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