@@ -63,7 +63,7 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
6363
6464 # assign some values to runtime components
6565 for lvl in range (pc .finest_level + 1 ):
66- for pti in pc .iterator (pc , level = lvl ):
66+ for pti in pc .iterator (level = lvl ):
6767 soa = pti .soa ()
6868 soa .get_real_data (2 ).assign (1.2345 )
6969 soa .get_int_data (1 ).assign (42 )
@@ -97,7 +97,7 @@ def soa_particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
9797
9898 # assign some values to runtime components
9999 for lvl in range (pc .finest_level + 1 ):
100- for pti in pc .iterator (pc , level = lvl ):
100+ for pti in pc .iterator (level = lvl ):
101101 soa = pti .soa ()
102102 soa .get_real_data (8 ).assign (1.2345 )
103103 soa .get_int_data (0 ).assign (42 )
@@ -212,7 +212,7 @@ def test_pc_init():
212212 # lvl = 0
213213 for lvl in range (pc .finest_level + 1 ):
214214 print (f"at level { lvl } :" )
215- for pti in pc .iterator (pc , level = lvl ):
215+ for pti in pc .iterator (level = lvl ):
216216 print ("..." )
217217 assert pti .num_particles == 1
218218 assert pti .num_real_particles == 1
@@ -243,7 +243,7 @@ def test_pc_init():
243243
244244 # read-only
245245 for lvl in range (pc .finest_level + 1 ):
246- for pti in pc .const_iterator (pc , level = lvl ):
246+ for pti in pc .const_iterator (level = lvl ):
247247 assert pti .num_particles == 1
248248 assert pti .num_real_particles == 1
249249 assert pti .num_neighbor_particles == 0
@@ -383,17 +383,17 @@ class Config:
383383 # iterate over mesh-refinement levels
384384 for lvl in range (pc .finest_level + 1 ):
385385 # loop local tiles of particles
386- for pti in pc .iterator (pc , level = lvl ):
386+ for pti in pc .iterator (level = lvl ):
387387 # compile-time and runtime attributes
388388 soa = pti .soa ().to_xp ()
389389
390- # print all particle ids in the chunk
390+ # print all particle ids in the tile
391391 print ("idcpu =" , soa .idcpu )
392392
393393 x = soa .real ["x" ]
394394 y = soa .real ["y" ]
395395
396- # write to all particles in the chunk
396+ # write to all particles in the tile
397397 # note: careful, if you change particle positions, you might need to
398398 # redistribute particles before continuing the simulation step
399399 soa .real ["x" ][:] = 0.30
@@ -410,6 +410,36 @@ class Config:
410410 soa_int [:] = 12
411411 # Manual: Pure SoA Compute PC Detailed END
412412
413+ # Manual: Pure SoA Compute PC Simple pti START
414+ # code-specific getter function, e.g.:
415+ # pc = sim.get_particles()
416+ # Config = sim.extension.Config
417+
418+ # iterate over particles on level 0
419+ for pti in pc .iterator (level = 0 ):
420+ # print all particle ids in the tile
421+ print ("idcpu =" , pti ["idcpu" ])
422+
423+ x = pti ["x" ] # this is automatically a cupy or numpy
424+ y = pti ["y" ] # array, depending on Config.have_gpu
425+
426+ # write to all particles in the chunk
427+ # note: careful, if you change particle positions, you might need to
428+ # redistribute particles before continuing the simulation step
429+ pti ["x" ][:] = 0.30
430+ pti ["y" ][:] = 0.35
431+ pti ["z" ][:] = 0.40
432+
433+ pti ["a" ][:] = x [:] ** 2
434+ pti ["b" ][:] = x [:] + y [:]
435+ pti ["c" ][:] = 0.50
436+ # ...
437+
438+ # int attributes
439+ pti ["i1" ][:] = 12
440+ pti ["i2" ][:] = 13
441+ # Manual: Pure SoA Compute PC Simple pti END
442+
413443
414444def test_pc_numpy (particle_container , Npart ):
415445 """Used in docs/source/usage/compute.rst"""
@@ -427,7 +457,7 @@ class Config:
427457 # iterate over mesh-refinement levels
428458 for lvl in range (pc .finest_level + 1 ):
429459 # loop local tiles of particles
430- for pti in pc .iterator (pc , level = lvl ):
460+ for pti in pc .iterator (level = lvl ):
431461 # default layout: AoS with positions and idcpu
432462 # note: not part of the new PureSoA particle container layout
433463 aos = (
0 commit comments