aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/_libwarpx.py
diff options
context:
space:
mode:
authorGravatar Grote <grote1@n9459722.llnl.gov> 2017-03-27 16:45:04 -0700
committerGravatar Grote <grote1@n9459722.llnl.gov> 2017-03-27 16:45:04 -0700
commit2213e9554ef445f8deb50c127ee2a6e41aced749 (patch)
tree5e01608235686b223730a2a2ba4f394285d5c327 /Python/pywarpx/_libwarpx.py
parentdcd1b263284c78d51c9530abeae63a642df23b7f (diff)
downloadWarpX-2213e9554ef445f8deb50c127ee2a6e41aced749.tar.gz
WarpX-2213e9554ef445f8deb50c127ee2a6e41aced749.tar.zst
WarpX-2213e9554ef445f8deb50c127ee2a6e41aced749.zip
Ported ctypes Particle fix to main Python version
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-xPython/pywarpx/_libwarpx.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 40b3aaf32..11e07e2a1 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -24,11 +24,20 @@ 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)
+p_dtype = np.dtype(p_struct, align=True)
# some useful typenames
+LP_particle_p = ctypes.POINTER(ctypes.POINTER(Particle))
LP_c_int = ctypes.POINTER(ctypes.c_int)
LP_c_void_p = ctypes.POINTER(ctypes.c_void_p)
LP_c_double = ctypes.POINTER(ctypes.c_double)
@@ -59,7 +68,7 @@ f = libwarpx.amrex_init
f.argtypes = (ctypes.c_int, LP_LP_c_char)
f = libwarpx.warpx_getParticleStructs
-f.restype = LP_c_void_p
+f.restype = LP_particle_p
f = libwarpx.warpx_getParticleArrays
f.restype = LP_LP_c_double