aboutsummaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorGravatar Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> 2022-08-10 18:37:14 +0200
committerGravatar GitHub <noreply@github.com> 2022-08-10 09:37:14 -0700
commitb4686616d884e11f4a624989d370b3c032d0c1c4 (patch)
tree656ecada72edfcb2217f0220403792c655857c18 /Python
parentb13e7f53959656a8d47adc63f20d9ed055288be0 (diff)
downloadWarpX-b4686616d884e11f4a624989d370b3c032d0c1c4.tar.gz
WarpX-b4686616d884e11f4a624989d370b3c032d0c1c4.tar.zst
WarpX-b4686616d884e11f4a624989d370b3c032d0c1c4.zip
Initialize particle runtime attributes inside AddNParticles (#3272)
* Initialize particle runtime attributes before calling AddNParticles * Avoid Multiplication result converted to larger type warning * Directly initialize runtime attributes inside AddNParticles * Update doxygen comment
Diffstat (limited to 'Python')
-rwxr-xr-xPython/pywarpx/_libwarpx.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 65a4d3cd5..fcf7f45d6 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -268,6 +268,8 @@ class LibWarpX():
_ndpointer(c_particlereal, flags="C_CONTIGUOUS"),
ctypes.c_int,
_ndpointer(c_particlereal, flags="C_CONTIGUOUS"),
+ ctypes.c_int,
+ _ndpointer(ctypes.c_int, flags="C_CONTIGUOUS"),
ctypes.c_int)
self.libwarpx_so.warpx_getProbLo.restype = c_real
@@ -625,6 +627,9 @@ class LibWarpX():
# --- The -3 is because components 1 to 3 are velocities
attr[:,self.get_particle_comp_index(species_name, key)-3] = vals
+ nattr_int = 0
+ attr_int = np.empty([0], ctypes.c_int)
+
# Iff x/y/z/ux/uy/uz are not numpy arrays of the correct dtype, new
# array copies are made with the correct dtype
x = x.astype(self._numpy_particlereal_dtype, copy=False)
@@ -636,7 +641,7 @@ class LibWarpX():
self.libwarpx_so.warpx_addNParticles(
ctypes.c_char_p(species_name.encode('utf-8')), x.size,
- x, y, z, ux, uy, uz, nattr, attr, unique_particles
+ x, y, z, ux, uy, uz, nattr, attr, nattr_int, attr_int, unique_particles
)
def get_particle_count(self, species_name, local=False):