From faf529ecf901f6379e3d2ad270c79459ef089a8e 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 | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/test_particleContainer.py b/tests/test_particleContainer.py index 36d9065b..b7ddb1fb 100644 --- a/tests/test_particleContainer.py +++ b/tests/test_particleContainer.py @@ -46,6 +46,28 @@ 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) + + print(f"num_real_comps={pc.num_real_comps}") + print(f"num_runtime_real_comps={pc.num_runtime_real_comps}") + + # 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 @@ -58,6 +80,28 @@ 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) + + print(f"num_real_comps={pc.num_real_comps}") + print(f"num_runtime_real_comps={pc.num_runtime_real_comps}") + + # 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 @@ -415,6 +459,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" @@ -462,3 +508,5 @@ def test_pc_df_mpi(particle_container, Npart): # only rank 0 print(df.columns) print(df) + + assert len(df.columns) == 12