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 ea955b1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 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 Expand Up @@ -286,6 +305,8 @@ def test_pc_df(particle_container, Npart):
print(df.columns)
print(df)

assert len(df.columns) == 12


@pytest.mark.skipif(
importlib.util.find_spec("pandas") is None, reason="pandas is not available"
Expand All @@ -309,3 +330,5 @@ def test_pc_df_mpi(particle_container, Npart):
# only rank 0
print(df.columns)
print(df)

assert len(df.columns) == 12

0 comments on commit ea955b1

Please sign in to comment.