@@ -4,6 +4,7 @@ cimport numpy as np # import special compile-time information about numpy
44cimport openmp
55np.import_array() # don't remove or you'll segfault
66from libc.string cimport memcpy
7+ import sys
78
89cdef extern from " ../../atomistic/lib/clib.h" :
910 void normalise(double * m, int nxyz)
@@ -179,6 +180,9 @@ cdef class CvodeSolver(object):
179180 self .check_flag(flag, " CVodeSetUserData" )
180181
181182 self .cvode_already_initialised = 0
183+
184+ self .u_y = N_VMake_Serial(self .y.size, < realtype * > self .y.data)
185+
182186 self .set_initial_value(spins, self .t)
183187 self .set_options(rtol, atol)
184188
@@ -191,7 +195,7 @@ cdef class CvodeSolver(object):
191195 self .y[:] = spin[:]
192196
193197 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 )
195199
196200 if self .cvode_already_initialised:
197201 flag = CVodeReInit(self .cvode_mem, t, self .u_y)
@@ -363,6 +367,9 @@ cdef class CvodeSolver_OpenMP(object):
363367 self .check_flag(flag, " CVodeSetUserData" )
364368
365369 self .cvode_already_initialised = 0
370+
371+ self .u_y = N_VMake_OpenMP(self .y.size, < realtype * > self .y.data, self .num_threads)
372+
366373 self .set_initial_value(spins, self .t)
367374 self .set_options(rtol, atol)
368375
@@ -375,7 +382,7 @@ cdef class CvodeSolver_OpenMP(object):
375382 self .y[:] = spin[:]
376383
377384 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 )
379386
380387 if self .cvode_already_initialised:
381388 flag = CVodeReInit(self .cvode_mem, t, self .u_y)
0 commit comments