diff options
author | 2017-03-27 17:12:48 -0700 | |
---|---|---|
committer | 2017-03-27 17:12:48 -0700 | |
commit | fa47be6293b5cd36d43e7f1aa7cd24b6c87d95e1 (patch) | |
tree | 728573d9b1f4dd631dc699ee26eb95698996792b /Python/pywarpx | |
parent | 2213e9554ef445f8deb50c127ee2a6e41aced749 (diff) | |
download | WarpX-fa47be6293b5cd36d43e7f1aa7cd24b6c87d95e1.tar.gz WarpX-fa47be6293b5cd36d43e7f1aa7cd24b6c87d95e1.tar.zst WarpX-fa47be6293b5cd36d43e7f1aa7cd24b6c87d95e1.zip |
Make the ctypes particle class work for 2d and 3d
Diffstat (limited to 'Python/pywarpx')
-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) |