From ea955b1d0b88c2163d8551159a13ed01e793c60c Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 6 Nov 2023 14:18:18 -0800 Subject: [PATCH] ParticleContainer Tests: w/ Runtime Attributes --- tests/test_particleContainer.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_particleContainer.py b/tests/test_particleContainer.py index 9f1897e4..74c7cb21 100644 --- a/tests/test_particleContainer.py +++ b/tests/test_particleContainer.py @@ -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 @@ -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 @@ -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 @@ -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" @@ -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