From 489270184ba9e03cb9996c614050cb92513424e6 Mon Sep 17 00:00:00 2001
From: David Bold <dave@ipp.mpg.de>
Date: Thu, 17 Nov 2022 13:37:33 +0100
Subject: [PATCH] Call PCGAMGSetSymGraph only with old PETSc
For newer PETSc set the option on the matrix
---
src/invert/laplace/impls/petsc3damg/petsc3damg.cxx | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx b/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx
index 210e41cbb3..81e5f4ce88 100644
--- a/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx
+++ b/src/invert/laplace/impls/petsc3damg/petsc3damg.cxx
@@ -457,6 +457,10 @@ void LaplacePetsc3dAmg::updateMatrix3D() {
operator3D.assemble();
MatSetBlockSize(*operator3D.get(), 1);
+#if PETSC_VERSION_GE(3, 18, 0)
+ MatSetOption(*operator3D.get(), MAT_SYMMETRIC, PETSC_TRUE);
+#endif
+
// Declare KSP Context (abstract PETSc object that manages all Krylov methods)
if (kspInitialised) {
KSPDestroy(&ksp);
@@ -508,7 +512,9 @@ void LaplacePetsc3dAmg::updateMatrix3D() {
// Set the relative and absolute tolerances
PCSetType(pc, pctype.c_str());
+#if PETSC_VERSION_LT(3, 18, 0)
PCGAMGSetSymGraph(pc, PETSC_TRUE);
+#endif
}
lib.setOptionsFromInputFile(ksp);