Skip to content

Commit

Permalink
Update get_particle_id/cpu
Browse files Browse the repository at this point in the history
As implemented in pyAMReX with
AMReX-Codes/pyamrex#165
  • Loading branch information
ax3l committed Aug 2, 2023
1 parent c9f44bd commit 0955ae9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Python/pywarpx/_libwarpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def load_library(self):
except ImportError:
raise Exception(f"Dimensionality '{self.geometry_dim}' was not compiled in this Python install. Please recompile with -DWarpX_DIMS={_dims}")

# matching space-dim of pyAMReX module
self.amr = self.libwarpx_so.amr

def getNProcs(self):
'''
Expand Down
16 changes: 2 additions & 14 deletions Python/pywarpx/particle_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,8 @@ def get_particle_id(self, level=0):
numbers on each tile.
'''
raise NotImplementedError()
ids = []
structs = self.get_particle_structs(level)
for ptile_of_structs in structs:
arr = np.empty(ptile_of_structs.shape, np.int64)
self.libwarpx_so.warpx_convert_id_to_long(arr, ptile_of_structs, arr.size)
ids.append(arr)
return ids
return [libwarpx.amr.unpack_ids(struct['cpuid']) for struct in structs]

def get_particle_cpu(self, level=0):
'''
Expand All @@ -264,14 +258,8 @@ def get_particle_cpu(self, level=0):
numbers on each tile.
'''
raise NotImplementedError()
cpus = []
structs = self.get_particle_structs(level)
for ptile_of_structs in structs:
arr = np.empty(ptile_of_structs.shape, np.int32)
self.libwarpx_so.warpx_convert_cpu_to_int(arr, ptile_of_structs, arr.size)
cpus.append(arr)
return cpus
return [libwarpx.amr.unpack_cpus(struct['cpuid']) for struct in structs]

def get_particle_x(self, level=0):
'''
Expand Down

0 comments on commit 0955ae9

Please sign in to comment.