aboutsummaryrefslogtreecommitdiff
path: root/src/petsc_defines.h
blob: 6c0a7021ce5379cd1d60b01e15d399499b95ae6e (plain)
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
#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)

/* Version 2.0.0 and higher */
#  include <sles.h>

#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 1

/* Version 2.1.0 and higher */
#  include <petscsles.h>

#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 2 && PETSC_VERSION_SUBMINOR == 0

/* Version 2.2.0 */
#  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

#elif PETSC_VERSION_MAJOR == 2 && PETSC_VERSION_MINOR == 2

/* Version 2.2.1 and higher */
#  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

#else

/* Version 2.3.0 and higher */
#  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
#  define PetscSetCommWorld(a) (PETSC_COMM_WORLD = (a), 0)

#endif

#endif /* #ifndef PETSC_DEFINES_H */