@@ -10,13 +10,14 @@ cdef extern from "sundials/sundials_context.h":
1010 struct _SUNContext:
1111 pass
1212 ctypedef _SUNContext * SUNContext
13+ void * SUN_COMM_NULL
1314 int SUNContext_Create(void * comm, SUNContext * ctx)
1415 int SUNContext_Free(SUNContext * ctx)
1516
1617
1718cdef extern from " sundials/sundials_types.h" :
18- ctypedef double realtype
19- ctypedef bint booleantype
19+ ctypedef double sunsunrealtype
20+ ctypedef bint sunsunbooleantype
2021
2122# Types for the Sundials Linear System initialization
2223cdef extern from " sundials/sundials_matrix.h" :
@@ -42,22 +43,22 @@ cdef extern from "sundials/sundials_nvector.h":
4243
4344
4445cdef extern from " nvector/nvector_serial.h" :
45- cdef N_Vector N_VMake_Serial(long int vec_length, realtype * v_data, SUNContext sunctx)
46+ cdef N_Vector N_VMake_Serial(long int vec_length, double * v_data, SUNContext sunctx)
4647 struct _N_VectorContent_Serial:
4748 long int length
48- realtype * data
49- booleantype own_data
49+ double * data
50+ int own_data
5051
5152 ctypedef _N_VectorContent_Serial * N_VectorContent_Serial
5253
5354
5455cdef extern from " nvector/nvector_openmp.h" :
55- cdef N_Vector N_VMake_OpenMP(long int vec_length, realtype * v_data, int num_threads, SUNContext sunctx)
56+ cdef N_Vector N_VMake_OpenMP(long int vec_length, double * v_data, int num_threads, SUNContext sunctx)
5657
5758 struct _N_VectorContent_OpenMP:
5859 long int length
59- realtype * data
60- booleantype own_data
60+ double * data
61+ int own_data
6162 int num_threads
6263
6364 ctypedef _N_VectorContent_OpenMP * N_VectorContent_OpenMP
@@ -100,34 +101,34 @@ cdef extern from "cvode/cvode.h":
100101 int CV_BAD_DKY
101102 int CV_TOO_CLOSE
102103
103- ctypedef int (* CVRhsFn)(realtype t, N_Vector y, N_Vector ydot, void * user_data)
104- ctypedef int (* CVRootFn)(realtype t, N_Vector y, realtype * gout, void * user_data)
104+ ctypedef int (* CVRhsFn)(double t, N_Vector y, N_Vector ydot, void * user_data)
105+ ctypedef int (* CVRootFn)(double t, N_Vector y, double * gout, void * user_data)
105106
106107 void * CVodeCreate(int lmm, SUNContext sunctx)
107- # int CVode "CVode"(void *cvode_mem, realtype tout, N_Vector yout, realtype *tret, int itask) nogil
108+ # int CVode "CVode"(void *cvode_mem, double tout, N_Vector yout, double *tret, int itask) nogil
108109 int CVodeSetUserData(void * cvode_mem, void * user_data)
109110 int CVodeSetMaxOrd(void * cvode_mem, int maxord)
110111 int CVodeSetMaxNumSteps(void * cvode_mem, long int mxsteps)
111112 int CVodeSetMaxHnilWarns(void * cvode_mem, int mxhnil)
112- int CVodeSetStabLimDet(void * cvode_mem, booleantype stldet)
113- int CVodeSetInitStep(void * cvode_mem, realtype hin)
114- int CVodeSetMinStep(void * cvode_mem, realtype hmin)
115- int CVodeSetMaxStep(void * cvode_mem, realtype hmax)
116- int CVodeSetStopTime(void * cvode_mem, realtype tstop)
113+ int CVodeSetStabLimDet(void * cvode_mem, int stldet)
114+ int CVodeSetInitStep(void * cvode_mem, double hin)
115+ int CVodeSetMinStep(void * cvode_mem, double hmin)
116+ int CVodeSetMaxStep(void * cvode_mem, double hmax)
117+ int CVodeSetStopTime(void * cvode_mem, double tstop)
117118 int CVodeSetMaxErrTestFails(void * cvode_mem, int maxnef)
118119 int CVodeSetMaxNonlinIters(void * cvode_mem, int maxcor)
119120 int CVodeSetMaxConvFails(void * cvode_mem, int maxncf)
120- int CVodeSetNonlinConvCoef(void * cvode_mem, realtype nlscoef)
121+ int CVodeSetNonlinConvCoef(void * cvode_mem, double nlscoef)
121122 int CVodeSetIterType(void * cvode_mem, int iter )
122123 int CVodeSetRootDirection(void * cvode_mem, int * rootdir)
123124 int CVodeSetNoInactiveRootWarn(void * cvode_mem)
124- int CVodeInit(void * cvode_mem, CVRhsFn f, realtype t0, N_Vector y0)
125- int CVodeReInit(void * cvode_mem, realtype t0, N_Vector y0)
126- int CVodeSStolerances(void * cvode_mem, realtype reltol, realtype abstol)
127- int CVodeSVtolerances(void * cvode_mem, realtype reltol, N_Vector abstol)
125+ int CVodeInit(void * cvode_mem, CVRhsFn f, double t0, N_Vector y0)
126+ int CVodeReInit(void * cvode_mem, double t0, N_Vector y0)
127+ int CVodeSStolerances(void * cvode_mem, double reltol, double abstol)
128+ int CVodeSVtolerances(void * cvode_mem, double reltol, N_Vector abstol)
128129 int CVodeRootInit(void * cvode_mem, int nrtfn, CVRootFn g)
129- int CVode(void * cvode_mem, realtype tout, N_Vector yout, realtype * tret, int itask)
130- int CVodeGetDky(void * cvode_mem, realtype t, int k, N_Vector dky)
130+ int CVode(void * cvode_mem, double tout, N_Vector yout, double * tret, int itask)
131+ int CVodeGetDky(void * cvode_mem, double t, int k, N_Vector dky)
131132 int CVodeGetWorkSpace(void * cvode_mem, long int * lenrw, long int * leniw)
132133 int CVodeGetNumSteps(void * cvode_mem, long int * nsteps)
133134 int CVodeGetNumRhsEvals(void * cvode_mem, long int * nfevals)
@@ -136,20 +137,20 @@ cdef extern from "cvode/cvode.h":
136137 int CVodeGetLastOrder(void * cvode_mem, int * qlast)
137138 int CVodeGetCurrentOrder(void * cvode_mem, int * qcur)
138139 int CVodeGetNumStabLimOrderReds(void * cvode_mem, long int * nslred)
139- int CVodeGetActualInitStep(void * cvode_mem, realtype * hinused)
140- int CVodeGetLastStep(void * cvode_mem, realtype * hlast)
141- int CVodeGetCurrentStep(void * cvode_mem, realtype * hcur)
142- int CVodeGetCurrentTime(void * cvode_mem, realtype * tcur)
143- int CVodeGetTolScaleFactor(void * cvode_mem, realtype * tolsfac)
140+ int CVodeGetActualInitStep(void * cvode_mem, double * hinused)
141+ int CVodeGetLastStep(void * cvode_mem, double * hlast)
142+ int CVodeGetCurrentStep(void * cvode_mem, double * hcur)
143+ int CVodeGetCurrentTime(void * cvode_mem, double * tcur)
144+ int CVodeGetTolScaleFactor(void * cvode_mem, double * tolsfac)
144145 int CVodeGetErrWeights(void * cvode_mem, N_Vector eweight)
145146 int CVodeGetEstLocalErrors(void * cvode_mem, N_Vector ele)
146147 int CVodeGetNumGEvals(void * cvode_mem, long int * ngevals)
147148 int CVodeGetRootInfo(void * cvode_mem, int * rootsfound)
148149 int CVodeGetIntegratorStats(void * cvode_mem, long int * nsteps,
149150 long int * nfevals, long int * nlinsetups,
150151 long int * netfails, int * qlast,
151- int * qcur, realtype * hinused, realtype * hlast,
152- realtype * hcur, realtype * tcur)
152+ int * qcur, double * hinused, double * hlast,
153+ double * hcur, double * tcur)
153154 int CVodeGetNumNonlinSolvIters(void * cvode_mem, long int * nniters)
154155 int CVodeGetNumNonlinSolvConvFails(void * cvode_mem, long int * nncfails)
155156 int CVodeGetNonlinSolvStats(void * cvode_mem, long int * nniters, long int * nncfails)
@@ -180,17 +181,17 @@ cdef extern from "cvode/cvode_ls.h":
180181 # int CVSpilsSetPrecType(void *cvode_mem, int pretype)
181182 # int CVSpilsSetGSType(void *cvode_mem, int gstype)
182183 # int CVSpilsSetMaxl(void *cvode_mem, int maxl)
183- # int CVSpilsSetEpsLin(void *cvode_mem, realtype eplifac)
184-
185- ctypedef int (* CVLsPrecSetupFn)(realtype t, N_Vector y, N_Vector fy,
186- booleantype jok, booleantype * jcurPtr,
187- realtype gamma, void * user_data);
188- ctypedef int (* CVLsPrecSolveFn)(realtype t, N_Vector y, N_Vector fy,
189- N_Vector r, N_Vector z, realtype gamma,
190- realtype delta, int lr, void * user_data);
191- ctypedef int (* CVLsJacTimesSetupFn)(realtype t, N_Vector y,
184+ # int CVSpilsSetEpsLin(void *cvode_mem, sunrealtype eplifac)
185+
186+ ctypedef int (* CVLsPrecSetupFn)(double t, N_Vector y, N_Vector fy,
187+ int jok, int * jcurPtr,
188+ double gamma, void * user_data);
189+ ctypedef int (* CVLsPrecSolveFn)(double t, N_Vector y, N_Vector fy,
190+ N_Vector r, N_Vector z, double gamma,
191+ double delta, int lr, void * user_data);
192+ ctypedef int (* CVLsJacTimesSetupFn)(double t, N_Vector y,
192193 N_Vector fy, void * user_data);
193- ctypedef int (* CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, realtype t,
194+ ctypedef int (* CVLsJacTimesVecFn)(N_Vector v, N_Vector Jv, double t,
194195 N_Vector y, N_Vector fy,
195196 void * user_data, N_Vector tmp);
196197
@@ -312,8 +313,8 @@ cdef int cv_jtimes_openmp(N_Vector v, N_Vector Jv, double t, N_Vector y, N_Vecto
312313 return 0
313314
314315
315- # static int PSolve(realtype tn, N_Vector u, N_Vector fu, N_Vector r, N_Vector z,
316- # realtype gamma, realtype delta, int lr, void *user_data);
316+ # static int PSolve(sunrealtype tn, N_Vector u, N_Vector fu, N_Vector r, N_Vector z,
317+ # sunrealtype gamma, sunrealtype delta, int lr, void *user_data);
317318cdef int psolve(double t, N_Vector y, N_Vector fy, N_Vector r, N_Vector z,
318319 double gamma, double delta, int lr, void * user_data):
319320 copy_nv2nv(z, r)
@@ -375,7 +376,7 @@ cdef class CvodeSolver(object):
375376 # All of the SUNDIALS objects (vectors, linear and nonlinear solvers, matrices, etc.)
376377 # that collectively form a SUNDIALS simulation, hold a reference to a common simulation context object
377378 # defined by the SUNContext class.
378- SUNContext_Create(NULL , & self .sunctx);
379+ SUNContext_Create(SUN_COMM_NULL , & self .sunctx);
379380
380381 # The recommended choices for lmm are CV ADAMS for nonstiff problems and CV BDF for
381382 # stiff problems. The default Newton iteration is recommended for stiff problems, and
@@ -504,10 +505,10 @@ cdef class CvodeSolver(object):
504505 return 0
505506
506507 # From exmaples: cvDiurnal_kry.c in Sundials repo:
507- # static int Precond(realtype tn, N_Vector u, N_Vector fu, booleantype jok,
508- # booleantype *jcurPtr, realtype gamma, void *user_data)
509- cdef int Precond(self , double t, N_Vector y, N_Vector fy, booleantype jok,
510- booleantype * jcurPtr, double gamma, void * user_data):
508+ # static int Precond(sunrealtype tn, N_Vector u, N_Vector fu, sunbooleantype jok,
509+ # sunbooleantype *jcurPtr, sunrealtype gamma, void *user_data)
510+ cdef int Precond(self , double t, N_Vector y, N_Vector fy, int jok,
511+ int * jcurPtr, double gamma, void * user_data):
511512 if not jok:
512513 copy_nv2arr(y, self .y)
513514 return 0
@@ -600,7 +601,7 @@ cdef class CvodeSolver_OpenMP(object):
600601 if jtimes_fun is not None :
601602 self .has_jtimes = 1
602603
603- SUNContext_Create(NULL , & self .sunctx);
604+ SUNContext_Create(SUN_COMM_NULL , & self .sunctx);
604605 # Newton iterator is set by default now (Sundials 4.0)
605606 self .cvode_mem = CVodeCreate(CV_BDF, self .sunctx)
606607
@@ -702,7 +703,7 @@ cdef class CvodeSolver_OpenMP(object):
702703 return 0
703704
704705 cdef int Precond(self , double t, N_Vector y, N_Vector fy,
705- booleantype jok, booleantype * jcurPtr, double gamma,
706+ int jok, int * jcurPtr, double gamma,
706707 void * user_data):
707708 if not jok:
708709 copy_nv2arr_openmp(y, self .y)
0 commit comments