@@ -4,6 +4,7 @@ cimport numpy as np # import special compile-time information about numpy
4
4
cimport openmp
5
5
np.import_array() # don't remove or you'll segfault
6
6
from libc.string cimport memcpy
7
+ import sys
7
8
8
9
cdef extern from " ../../atomistic/lib/clib.h" :
9
10
void normalise(double * m, int nxyz)
@@ -179,6 +180,9 @@ cdef class CvodeSolver(object):
179
180
self .check_flag(flag, " CVodeSetUserData" )
180
181
181
182
self .cvode_already_initialised = 0
183
+
184
+ self .u_y = N_VMake_Serial(self .y.size, < realtype * > self .y.data)
185
+
182
186
self .set_initial_value(spins, self .t)
183
187
self .set_options(rtol, atol)
184
188
@@ -191,7 +195,7 @@ cdef class CvodeSolver(object):
191
195
self .y[:] = spin[:]
192
196
193
197
cdef np.ndarray[double , ndim = 1 , mode = " c" ] y = self .y
194
- self .u_y = N_VMake_Serial(y.size, & y[ 0 ] )
198
+ copy_arr2nv( self .y, self .u_y )
195
199
196
200
if self .cvode_already_initialised:
197
201
flag = CVodeReInit(self .cvode_mem, t, self .u_y)
@@ -363,6 +367,9 @@ cdef class CvodeSolver_OpenMP(object):
363
367
self .check_flag(flag, " CVodeSetUserData" )
364
368
365
369
self .cvode_already_initialised = 0
370
+
371
+ self .u_y = N_VMake_OpenMP(self .y.size, < realtype * > self .y.data, self .num_threads)
372
+
366
373
self .set_initial_value(spins, self .t)
367
374
self .set_options(rtol, atol)
368
375
@@ -375,7 +382,7 @@ cdef class CvodeSolver_OpenMP(object):
375
382
self .y[:] = spin[:]
376
383
377
384
cdef np.ndarray[double , ndim = 1 , mode = " c" ] y = self .y
378
- self .u_y = N_VMake_OpenMP(y.size, & y[ 0 ], self .num_threads )
385
+ copy_arr2nv_openmp( self .y, self .u_y )
379
386
380
387
if self .cvode_already_initialised:
381
388
flag = CVodeReInit(self .cvode_mem, t, self .u_y)
0 commit comments