diff --git a/src/lib/sundials_callbacks.pxi b/src/lib/sundials_callbacks.pxi index f5a48861..e970aea8 100644 --- a/src/lib/sundials_callbacks.pxi +++ b/src/lib/sundials_callbacks.pxi @@ -24,7 +24,10 @@ from numpy cimport PyArray_DATA cdef N_Vector N_VNewEmpty_Euclidean(long int n) noexcept: IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector v = N_VNew_Serial(n, ctx) ELSE: @@ -39,7 +42,10 @@ cdef inline N_Vector arr2nv(x) noexcept: cdef void* data_ptr=PyArray_DATA(ndx) IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector v = N_VNew_Serial(n, ctx) ELSE: diff --git a/src/lib/sundials_includes.pxd b/src/lib/sundials_includes.pxd index 42816133..8443a02b 100644 --- a/src/lib/sundials_includes.pxd +++ b/src/lib/sundials_includes.pxd @@ -36,7 +36,11 @@ IF SUNDIALS_VERSION >= (6,0,0): ctypedef _SUNContext * SUNContext cdef struct _SUNContext: pass - int SUNContext_Create(void* comm, SUNContext* ctx) noexcept + IF SUNDIALS_VERSION >= (7,0,0): + ctypedef int SUNComm + int SUNContext_Create(SUNComm comm, SUNContext* ctx) noexcept + ELSE: + int SUNContext_Create(void* comm, SUNContext* ctx) noexcept IF SUNDIALS_VERSION >= (7,0,0): cdef extern from "sundials/sundials_context.h": diff --git a/src/solvers/kinsol.pyx b/src/solvers/kinsol.pyx index de9bd9e3..3c31e523 100644 --- a/src/solvers/kinsol.pyx +++ b/src/solvers/kinsol.pyx @@ -183,7 +183,10 @@ cdef class KINSOL(Algebraic): cdef int flag #Used for return IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) self.y_temp = arr2nv(self.y) @@ -230,7 +233,10 @@ cdef class KINSOL(Algebraic): cpdef add_linear_solver(self): IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) if self.options["linear_solver"] == "DENSE": IF SUNDIALS_VERSION >= (3,0,0): diff --git a/src/solvers/sundials.pyx b/src/solvers/sundials.pyx index 84cc9b6e..5543b124 100644 --- a/src/solvers/sundials.pyx +++ b/src/solvers/sundials.pyx @@ -239,7 +239,10 @@ cdef class IDA(Implicit_ODE): cdef realtype ZERO = 0.0 IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) self.yTemp = arr2nv(self.y) @@ -739,7 +742,10 @@ cdef class IDA(Implicit_ODE): cdef np.ndarray err, pyweight, pyele IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector ele = N_VNew_Serial(self.pData.dim, ctx) cdef N_Vector eweight = N_VNew_Serial(self.pData.dim, ctx) @@ -774,7 +780,10 @@ cdef class IDA(Implicit_ODE): cdef np.ndarray res IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector dky=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -815,7 +824,10 @@ cdef class IDA(Implicit_ODE): """ IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector dkyS=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -1614,7 +1626,10 @@ cdef class CVode(Explicit_ODE): cdef int flag IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector ele=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -1696,7 +1711,10 @@ cdef class CVode(Explicit_ODE): cdef int flag IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector eweight=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -1770,7 +1788,10 @@ cdef class CVode(Explicit_ODE): cdef realtype ZERO = 0.0 IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void * comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) if self.options["norm"] == "EUCLIDEAN": @@ -1930,7 +1951,10 @@ cdef class CVode(Explicit_ODE): cdef np.ndarray res IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector dky=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -1972,7 +1996,10 @@ cdef class CVode(Explicit_ODE): """ IF SUNDIALS_VERSION >= (6,0,0): cdef SUNDIALS.SUNContext ctx = NULL - cdef void* comm = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) cdef N_Vector dkyS=N_VNew_Serial(self.pData.dim, ctx) ELSE: @@ -2251,8 +2278,11 @@ cdef class CVode(Explicit_ODE): """ cdef flag IF SUNDIALS_VERSION >= (6,0,0): - cdef SUNDIALS.SUNContext ctx - cdef void* comm = NULL + cdef SUNDIALS.SUNContext ctx = NULL + IF SUNDIALS_VERSION >= (7,0,0): + cdef SUNDIALS.SUNComm comm = 0 + ELSE: + cdef void* comm = NULL SUNDIALS.SUNContext_Create(comm, &ctx) #Choose a linear solver if and only if NEWTON is choosen