diff options
Diffstat (limited to 'Python')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index 11e07e2a1..054d8b11f 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -24,18 +24,18 @@ libc = ctypes.CDLL(find_library('c')) dim = libwarpx.warpx_SpaceDim() -class Particle(ctypes.Structure): - _fields_ = [('x', ctypes.c_double), - ('y', ctypes.c_double), - ('z', ctypes.c_double), - ('id', ctypes.c_int), - ('cpu', ctypes.c_int)] - - # our particle data type p_struct = [(d, 'f8') for d in 'xyz'[:dim]] + [('id', 'i4'), ('cpu', 'i4')] p_dtype = np.dtype(p_struct, align=True) +numpy_to_ctypes = {} +numpy_to_ctypes['f8'] = ctypes.c_double +numpy_to_ctypes['i4'] = ctypes.c_int + +class Particle(ctypes.Structure): + _fields_ = [(v[0], numpy_to_ctypes[v[1]]) for v in p_struct] + + # some useful typenames LP_particle_p = ctypes.POINTER(ctypes.POINTER(Particle)) LP_c_int = ctypes.POINTER(ctypes.c_int) |