Skip to content

Commit

Permalink
ParticleContainer Tests: w/ Runtime Attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Nov 6, 2023
1 parent 6bb6ef9 commit 84a3a78
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tests/test_particleContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):

iseed = 1
pc.InitRandom(Npart, iseed, myt, False, std_real_box)

# add runtime components: 1 real 2 int
pc.add_real_comp(True)
pc.add_int_comp(True)
pc.add_int_comp(True)

# can be removed after
# https://github.com/AMReX-Codes/amrex/pull/3615
pc.resize_runtime_real_comp(1, True)
pc.resize_runtime_int_comp(2, True)

# assign some values to runtime components
for lvl in range(pc.finest_level + 1):
for pti in pc.iterator(pc, level=lvl):
soa = pti.soa()
soa.GetRealData(2).assign(1.2345)
soa.GetIntData(1).assign(42)
soa.GetIntData(2).assign(33)

return pc


Expand Down Expand Up @@ -129,7 +148,7 @@ def test_pc_init():
# lvl = 0
for lvl in range(pc.finest_level + 1):
print(f"at level {lvl}:")
for pti in amr.ParIter_1_1_2_1_default(pc, level=lvl):
for pti in pc.iterator(pc, level=lvl):
print("...")
assert pti.num_particles == 1
assert pti.num_real_particles == 1
Expand Down Expand Up @@ -158,7 +177,7 @@ def test_pc_init():

# read-only
for lvl in range(pc.finest_level + 1):
for pti in amr.ParConstIter_1_1_2_1_default(pc, level=lvl):
for pti in pc.const_iterator(pc, level=lvl):
assert pti.num_particles == 1
assert pti.num_real_particles == 1
assert pti.num_neighbor_particles == 0
Expand Down

0 comments on commit 84a3a78

Please sign in to comment.