Skip to content

Commit 90a106f

Browse files
committed
ParticleContainer Tests: w/ Runtime Attributes
1 parent 85ef39f commit 90a106f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tests/test_particleContainer.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
4040

4141
iseed = 1
4242
pc.InitRandom(Npart, iseed, myt, False, std_real_box)
43+
44+
# add runtime components: 1 real 2 int
45+
pc.add_real_comp(True)
46+
pc.add_int_comp(True)
47+
pc.add_int_comp(True)
48+
49+
# can be removed after
50+
# https://github.com/AMReX-Codes/amrex/pull/3615
51+
pc.resize_runtime_real_comp(1, True)
52+
pc.resize_runtime_int_comp(2, True)
53+
54+
# assign some values to runtime components
55+
for lvl in range(pc.finest_level + 1):
56+
for pti in pc.iterator(pc, level=lvl):
57+
soa = pti.soa()
58+
soa.GetRealData(2).assign(1.2345)
59+
soa.GetIntData(1).assign(42)
60+
soa.GetIntData(2).assign(33)
61+
4362
return pc
4463

4564

@@ -129,7 +148,7 @@ def test_pc_init():
129148
# lvl = 0
130149
for lvl in range(pc.finest_level + 1):
131150
print(f"at level {lvl}:")
132-
for pti in amr.ParIter_1_1_2_1_default(pc, level=lvl):
151+
for pti in pc.iterator(pc, level=lvl):
133152
print("...")
134153
assert pti.num_particles == 1
135154
assert pti.num_real_particles == 1
@@ -158,7 +177,7 @@ def test_pc_init():
158177

159178
# read-only
160179
for lvl in range(pc.finest_level + 1):
161-
for pti in amr.ParConstIter_1_1_2_1_default(pc, level=lvl):
180+
for pti in pc.const_iterator(pc, level=lvl):
162181
assert pti.num_particles == 1
163182
assert pti.num_real_particles == 1
164183
assert pti.num_neighbor_particles == 0
@@ -286,6 +305,8 @@ def test_pc_df(particle_container, Npart):
286305
print(df.columns)
287306
print(df)
288307

308+
assert len(df.columns) == 12
309+
289310

290311
@pytest.mark.skipif(
291312
importlib.util.find_spec("pandas") is None, reason="pandas is not available"
@@ -309,3 +330,5 @@ def test_pc_df_mpi(particle_container, Npart):
309330
# only rank 0
310331
print(df.columns)
311332
print(df)
333+
334+
assert len(df.columns) == 12

0 commit comments

Comments
 (0)