Skip to content

Commit faf529e

Browse files
committed
ParticleContainer Tests: w/ Runtime Attributes
1 parent 0800ff6 commit faf529e

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/test_particleContainer.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ 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+
print(f"num_real_comps={pc.num_real_comps}")
61+
print(f"num_runtime_real_comps={pc.num_runtime_real_comps}")
62+
63+
# assign some values to runtime components
64+
for lvl in range(pc.finest_level + 1):
65+
for pti in pc.iterator(pc, level=lvl):
66+
soa = pti.soa()
67+
soa.get_real_data(2).assign(1.2345)
68+
soa.get_int_data(1).assign(42)
69+
soa.get_int_data(2).assign(33)
70+
4971
return pc
5072

5173

@@ -58,6 +80,28 @@ def soa_particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):
5880

5981
iseed = 1
6082
pc.init_random(Npart, iseed, myt, False, std_real_box)
83+
84+
# add runtime components: 1 real 2 int
85+
pc.add_real_comp(True)
86+
pc.add_int_comp(True)
87+
pc.add_int_comp(True)
88+
89+
# can be removed after
90+
# https://github.com/AMReX-Codes/amrex/pull/3615
91+
pc.resize_runtime_real_comp(1, True)
92+
pc.resize_runtime_int_comp(2, True)
93+
94+
print(f"num_real_comps={pc.num_real_comps}")
95+
print(f"num_runtime_real_comps={pc.num_runtime_real_comps}")
96+
97+
# assign some values to runtime components
98+
for lvl in range(pc.finest_level + 1):
99+
for pti in pc.iterator(pc, level=lvl):
100+
soa = pti.soa()
101+
soa.get_real_data(2).assign(1.2345)
102+
soa.get_int_data(0).assign(42)
103+
soa.get_int_data(1).assign(33)
104+
61105
return pc
62106

63107

@@ -415,6 +459,8 @@ def test_pc_df(particle_container, Npart):
415459
print(df.columns)
416460
print(df)
417461

462+
assert len(df.columns) == 12
463+
418464

419465
@pytest.mark.skipif(
420466
importlib.util.find_spec("pandas") is None, reason="pandas is not available"
@@ -462,3 +508,5 @@ def test_pc_df_mpi(particle_container, Npart):
462508
# only rank 0
463509
print(df.columns)
464510
print(df)
511+
512+
assert len(df.columns) == 12

0 commit comments

Comments
 (0)