Skip to content

Commit a38fc24

Browse files
committed
Add documentation for the Python particle gather routines
1 parent 280ec8e commit a38fc24

File tree

1 file changed

+169
-15
lines changed

1 file changed

+169
-15
lines changed

Python/pywarpx/particle_containers.py

Lines changed: 169 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ def get_particle_structs(self, level, copy_to_host=False):
203203
----------
204204
205205
level : int
206-
The refinement level to reference
206+
The refinement level to reference (default=0)
207207
208208
copy_to_host : bool
209209
For GPU-enabled runs, one can either return the GPU
210-
arrays or force a device-to-host copy.
210+
arrays (the default) or force a device-to-host copy.
211211
212212
Returns
213213
-------
@@ -252,11 +252,11 @@ def get_particle_arrays(self, comp_name, level, copy_to_host=False):
252252
The component of the array data that will be returned
253253
254254
level : int
255-
The refinement level to reference
255+
The refinement level to reference (default=0)
256256
257257
copy_to_host : bool
258258
For GPU-enabled runs, one can either return the GPU
259-
arrays or force a device-to-host copy.
259+
arrays (the default) or force a device-to-host copy.
260260
261261
Returns
262262
-------
@@ -286,30 +286,72 @@ def get_particle_arrays(self, comp_name, level, copy_to_host=False):
286286

287287
def get_particle_id(self, level=0, copy_to_host=False):
288288
'''
289-
290289
Return a list of numpy or cupy arrays containing the particle 'id'
291290
numbers on each tile.
292291
292+
Parameters
293+
----------
294+
295+
level : int
296+
The refinement level to reference (default=0)
297+
298+
copy_to_host : bool
299+
For GPU-enabled runs, one can either return the GPU
300+
arrays (the default) or force a device-to-host copy.
301+
302+
Returns
303+
-------
304+
305+
List of arrays
306+
The requested particle ids
293307
'''
294308
structs = self.get_particle_structs(level, copy_to_host)
295309
return [libwarpx.amr.unpack_ids(struct['cpuid']) for struct in structs]
296310

297311
def get_particle_cpu(self, level=0, copy_to_host=False):
298312
'''
299-
300313
Return a list of numpy or cupy arrays containing the particle 'cpu'
301314
numbers on each tile.
302315
316+
Parameters
317+
----------
318+
319+
level : int
320+
The refinement level to reference (default=0)
321+
322+
copy_to_host : bool
323+
For GPU-enabled runs, one can either return the GPU
324+
arrays (the default) or force a device-to-host copy.
325+
326+
Returns
327+
-------
328+
329+
List of arrays
330+
The requested particle cpus
303331
'''
304332
structs = self.get_particle_structs(level, copy_to_host)
305333
return [libwarpx.amr.unpack_cpus(struct['cpuid']) for struct in structs]
306334

307335
def get_particle_x(self, level=0, copy_to_host=False):
308336
'''
309-
310337
Return a list of numpy or cupy arrays containing the particle 'x'
311338
positions on each tile.
312339
340+
Parameters
341+
----------
342+
343+
level : int
344+
The refinement level to reference (default=0)
345+
346+
copy_to_host : bool
347+
For GPU-enabled runs, one can either return the GPU
348+
arrays (the default) or force a device-to-host copy.
349+
350+
Returns
351+
-------
352+
353+
List of arrays
354+
The requested particle x position
313355
'''
314356
xp, cupy_status = load_cupy()
315357

@@ -324,10 +366,24 @@ def get_particle_x(self, level=0, copy_to_host=False):
324366

325367
def get_particle_y(self, level=0, copy_to_host=False):
326368
'''
327-
328369
Return a list of numpy or cupy arrays containing the particle 'y'
329370
positions on each tile.
330371
372+
Parameters
373+
----------
374+
375+
level : int
376+
The refinement level to reference (default=0)
377+
378+
copy_to_host : bool
379+
For GPU-enabled runs, one can either return the GPU
380+
arrays (the default) or force a device-to-host copy.
381+
382+
Returns
383+
-------
384+
385+
List of arrays
386+
The requested particle y position
331387
'''
332388
xp, cupy_status = load_cupy()
333389

@@ -342,10 +398,24 @@ def get_particle_y(self, level=0, copy_to_host=False):
342398

343399
def get_particle_r(self, level=0, copy_to_host=False):
344400
'''
345-
346401
Return a list of numpy or cupy arrays containing the particle 'r'
347402
positions on each tile.
348403
404+
Parameters
405+
----------
406+
407+
level : int
408+
The refinement level to reference (default=0)
409+
410+
copy_to_host : bool
411+
For GPU-enabled runs, one can either return the GPU
412+
arrays (the default) or force a device-to-host copy.
413+
414+
Returns
415+
-------
416+
417+
List of arrays
418+
The requested particle r position
349419
'''
350420
xp, cupy_status = load_cupy()
351421

@@ -360,10 +430,24 @@ def get_particle_r(self, level=0, copy_to_host=False):
360430

361431
def get_particle_theta(self, level=0, copy_to_host=False):
362432
'''
363-
364433
Return a list of numpy or cupy arrays containing the particle
365434
theta on each tile.
366435
436+
Parameters
437+
----------
438+
439+
level : int
440+
The refinement level to reference (default=0)
441+
442+
copy_to_host : bool
443+
For GPU-enabled runs, one can either return the GPU
444+
arrays (the default) or force a device-to-host copy.
445+
446+
Returns
447+
-------
448+
449+
List of arrays
450+
The requested particle theta position
367451
'''
368452
xp, cupy_status = load_cupy()
369453

@@ -378,10 +462,24 @@ def get_particle_theta(self, level=0, copy_to_host=False):
378462

379463
def get_particle_z(self, level=0, copy_to_host=False):
380464
'''
381-
382465
Return a list of numpy or cupy arrays containing the particle 'z'
383466
positions on each tile.
384467
468+
Parameters
469+
----------
470+
471+
level : int
472+
The refinement level to reference (default=0)
473+
474+
copy_to_host : bool
475+
For GPU-enabled runs, one can either return the GPU
476+
arrays (the default) or force a device-to-host copy.
477+
478+
Returns
479+
-------
480+
481+
List of arrays
482+
The requested particle z position
385483
'''
386484
structs = self.get_particle_structs(level, copy_to_host)
387485
if libwarpx.geometry_dim == '3d':
@@ -394,40 +492,96 @@ def get_particle_z(self, level=0, copy_to_host=False):
394492

395493
def get_particle_weight(self, level=0, copy_to_host=False):
396494
'''
397-
398495
Return a list of numpy or cupy arrays containing the particle
399496
weight on each tile.
400497
498+
Parameters
499+
----------
500+
501+
level : int
502+
The refinement level to reference (default=0)
503+
504+
copy_to_host : bool
505+
For GPU-enabled runs, one can either return the GPU
506+
arrays (the default) or force a device-to-host copy.
507+
508+
Returns
509+
-------
510+
511+
List of arrays
512+
The requested particle weight
401513
'''
402514
return self.get_particle_arrays('w', level, copy_to_host=copy_to_host)
403515
wp = property(get_particle_weight)
404516

405517
def get_particle_ux(self, level=0, copy_to_host=False):
406518
'''
407-
408519
Return a list of numpy or cupy arrays containing the particle
409520
x momentum on each tile.
410521
522+
Parameters
523+
----------
524+
525+
level : int
526+
The refinement level to reference (default=0)
527+
528+
copy_to_host : bool
529+
For GPU-enabled runs, one can either return the GPU
530+
arrays (the default) or force a device-to-host copy.
531+
532+
Returns
533+
-------
534+
535+
List of arrays
536+
The requested particle x momentum
411537
'''
412538
return self.get_particle_arrays('ux', level, copy_to_host=copy_to_host)
413539
uxp = property(get_particle_ux)
414540

415541
def get_particle_uy(self, level=0, copy_to_host=False):
416542
'''
417-
418543
Return a list of numpy or cupy arrays containing the particle
419544
y momentum on each tile.
420545
546+
Parameters
547+
----------
548+
549+
level : int
550+
The refinement level to reference (default=0)
551+
552+
copy_to_host : bool
553+
For GPU-enabled runs, one can either return the GPU
554+
arrays (the default) or force a device-to-host copy.
555+
556+
Returns
557+
-------
558+
559+
List of arrays
560+
The requested particle y momentum
421561
'''
422562
return self.get_particle_arrays('uy', level, copy_to_host=copy_to_host)
423563
uyp = property(get_particle_uy)
424564

425565
def get_particle_uz(self, level=0, copy_to_host=False):
426566
'''
427-
428567
Return a list of numpy or cupy arrays containing the particle
429568
z momentum on each tile.
430569
570+
Parameters
571+
----------
572+
573+
level : int
574+
The refinement level to reference (default=0)
575+
576+
copy_to_host : bool
577+
For GPU-enabled runs, one can either return the GPU
578+
arrays (the default) or force a device-to-host copy.
579+
580+
Returns
581+
-------
582+
583+
List of arrays
584+
The requested particle z momentum
431585
'''
432586

433587
return self.get_particle_arrays('uz', level, copy_to_host=copy_to_host)

0 commit comments

Comments
 (0)