Skip to content

Commit 4d12259

Browse files
committed
ParticleContainer Tests: w/ Runtime Attributes
1 parent c9b50ea commit 4d12259

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/test_particleContainer.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
4646

4747
iseed = 1
4848
pc.init_random(Npart, iseed, myt, False, std_real_box)
49+
50+
# add runtime components: 1 real 2 int
51+
pc.add_real_comp(True)
52+
pc.add_int_comp(True)
53+
pc.add_int_comp(True)
54+
55+
# can be removed after
56+
# https://github.com/AMReX-Codes/amrex/pull/3615
57+
pc.resize_runtime_real_comp(1, True)
58+
pc.resize_runtime_int_comp(2, True)
59+
60+
# assign some values to runtime components
61+
for lvl in range(pc.finest_level + 1):
62+
for pti in pc.iterator(pc, level=lvl):
63+
soa = pti.soa()
64+
soa.get_real_data(2).assign(1.2345)
65+
soa.get_int_data(1).assign(42)
66+
soa.get_int_data(2).assign(33)
67+
4968
return pc
5069

5170

@@ -58,6 +77,25 @@ def soa_particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
5877

5978
iseed = 1
6079
pc.init_random(Npart, iseed, myt, False, std_real_box)
80+
81+
# add runtime components: 1 real 2 int
82+
pc.add_real_comp(True)
83+
pc.add_int_comp(True)
84+
pc.add_int_comp(True)
85+
86+
# can be removed after
87+
# https://github.com/AMReX-Codes/amrex/pull/3615
88+
pc.resize_runtime_real_comp(1, True)
89+
pc.resize_runtime_int_comp(2, True)
90+
91+
# assign some values to runtime components
92+
for lvl in range(pc.finest_level + 1):
93+
for pti in pc.iterator(pc, level=lvl):
94+
soa = pti.soa()
95+
soa.get_real_data(8).assign(1.2345)
96+
soa.get_int_data(0).assign(42)
97+
soa.get_int_data(1).assign(33)
98+
6199
return pc
62100

63101

@@ -414,6 +452,8 @@ def test_pc_df(particle_container, Npart):
414452
print(df.columns)
415453
print(df)
416454

455+
assert len(df.columns) == 12
456+
417457

418458
@pytest.mark.skipif(
419459
importlib.util.find_spec("pandas") is None, reason="pandas is not available"
@@ -502,3 +542,5 @@ def test_pc_df_mpi(particle_container, Npart):
502542
# only rank 0
503543
print(df.columns)
504544
print(df)
545+
546+
assert len(df.columns) == 12

0 commit comments

Comments
 (0)