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 Feb 16, 2024
1 parent 0800ff6 commit b534827
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/test_particleContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ def particle_container(Npart, std_geometry, distmap, boxarr, std_real_box):

iseed = 1
pc.init_random(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.get_real_data(2).assign(1.2345)
soa.get_int_data(1).assign(42)
soa.get_int_data(2).assign(33)

return pc


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

iseed = 1
pc.init_random(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.get_real_data(2).assign(1.2345)
soa.get_int_data(0).assign(42)
soa.get_int_data(1).assign(33)

return pc


Expand Down Expand Up @@ -415,6 +453,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 Down Expand Up @@ -462,3 +502,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 b534827

Please sign in to comment.