aboutsummaryrefslogtreecommitdiff
path: root/src/petsc_defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/petsc_defines.h')
-rw-r--r--src/petsc_defines.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/petsc_defines.h b/src/petsc_defines.h
new file mode 100644
index 0000000..19c321e
--- /dev/null
+++ b/src/petsc_defines.h
@@ -0,0 +1,63 @@
+#ifndef PETSC_DEFINES_H
+#define PETSC_DEFINES_H
+
+#include "cctk.h"
+
+#include <petsc.h>
+#include <petscversion.h>
+
+
+
+/* The PETSc API changes frequently, sometimes even in minor releases.
+ The #defines below map calls to the PETSc linear solver to the
+ corresponding PETSc call (or sequence of calls), depending on the
+ version of PETSc. */
+
+
+
+#if PETSC_VERSION_MAJOR < 2 || \
+ (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 0)
+
+/* Up to and including version 2.0.x */
+# include <sles.h>
+
+#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR <= 1
+
+/* Up to and including version 2.1.x */
+# include <petscsles.h>
+
+#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 2
+
+/* Version 2.2.x */
+# include <petscmat.h>
+# include <petscksp.h>
+# define SLES KSP
+# define SLESCreate KSPCreate
+# define SLESSetOperators KSPSetOperators
+# define SLESGetKSP(a,b) ((*b) = (a), 0)
+# define SLESGetPC KSPGetPC
+# define SLESSetFromOptions KSPSetFromOptions
+# define SLESSolve(a,b,c,d) (KSPSetRhs(a,b), \
+ KSPSetSolution(a,c), \
+ KSPSolve(a), \
+ KSPGetIterationNumber(a,d))
+# define SLESDestroy KSPDestroy
+
+#else
+
+/* Later versions */
+# include <petscmat.h>
+# include <petscksp.h>
+# define SLES KSP
+# define SLESCreate KSPCreate
+# define SLESSetOperators KSPSetOperators
+# define SLESGetKSP(a,b) ((*b) = (a), 0)
+# define SLESGetPC KSPGetPC
+# define SLESSetFromOptions KSPSetFromOptions
+# define SLESSolve(a,b,c,d) (KSPSolve(a,b,c), \
+ KSPGetIterationNumber(a,d))
+# define SLESDestroy KSPDestroy
+
+#endif
+
+#endif /* #ifndef PETSC_DEFINES_H */