From c14d14eca019ab32134593325466c734b2d87b3c Mon Sep 17 00:00:00 2001 From: schnetter Date: Mon, 6 Mar 2006 19:43:02 +0000 Subject: Clean up the backwards compatibility macros for PETSc. Incorporate Steve's changes for PETSc 2.2.x. git-svn-id: http://svn.cactuscode.org/arrangements/CactusElliptic/EllPETSc/trunk@94 1d96b42b-98df-4a6a-9d84-1b24288d4588 --- src/petsc_confmetric_solver.c | 23 +++------------- src/petsc_defines.h | 63 +++++++++++++++++++++++++++++++++++++++++++ src/petsc_flat_solver.c | 23 +++------------- 3 files changed, 69 insertions(+), 40 deletions(-) create mode 100644 src/petsc_defines.h diff --git a/src/petsc_confmetric_solver.c b/src/petsc_confmetric_solver.c index a95fa5a..dbce686 100644 --- a/src/petsc_confmetric_solver.c +++ b/src/petsc_confmetric_solver.c @@ -17,26 +17,9 @@ #include #include -#if PETSC_VERSION_MAJOR < 2 || (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 0) -/* Up to and including version 2.0.x */ -# include -#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR <= 1 -/* Up to and including version 2.1.x */ -# include -#else -/* Later versions */ -# include -# include -# 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 SLESSolve(a,b,c,d) (KSPSolve((a),(b),(c)),KSPGetIterationNumber(a,d)) -# define SLESDestroy KSPDestroy -#endif + +/* Include some definitions for backwards compatibility */ +#include "petsc_defines.h" #include "ellpetsc.h" #include "CactusPUGH/PUGH/src/include/pugh.h" 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 +#include + + + +/* 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 + +#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR <= 1 + +/* Up to and including version 2.1.x */ +# include + +#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 2 + +/* Version 2.2.x */ +# include +# include +# 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 +# include +# 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 */ diff --git a/src/petsc_flat_solver.c b/src/petsc_flat_solver.c index 200e233..8f392e4 100644 --- a/src/petsc_flat_solver.c +++ b/src/petsc_flat_solver.c @@ -16,26 +16,9 @@ #include #include -#if PETSC_VERSION_MAJOR < 2 || (PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 0) -/* Up to and including version 2.0.x */ -# include -#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR <= 1 -/* Up to and including version 2.1.x */ -# include -#else -/* Later versions */ -# include -# include -# 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 SLESSolve(a,b,c,d) (KSPSolve((a),(b),(c)),KSPGetIterationNumber(a,d)) -# define SLESDestroy KSPDestroy -#endif + +/* Include some definitions for backwards compatibility */ +#include "petsc_defines.h" #include "ellpetsc.h" #include "CactusPUGH/PUGH/src/include/pugh.h" -- cgit v1.2.3