コード例 #1
0
ファイル: test_geometry.py プロジェクト: rochSmets/PHARE
    def test_particle_ghost_area_boxes(self):
        hierarchy = self.basic_hierarchy()

        expected = {
            0: [Box(-1, -1), Box(33, 33), Box(32, 32), Box(65, 65)],
            1: [Box(9, 9), Box(60, 60), Box(63, 63), Box(112, 112)],
        }

        gaboxes = ghost_area_boxes(hierarchy, "particles")
        particles = "particles"

        # same number of levels
        self.assertEqual(len(expected), len(gaboxes))

        for ilvl, lvl in enumerate(hierarchy.patch_levels):
            qtyNbr = len(gaboxes[ilvl].keys())
            self.assertEqual(qtyNbr, 1)

            key = list(gaboxes[ilvl].keys())[0]

            level_ghost_area_boxes = sum(  # aggregate to single list
                [actual["boxes"] for actual in gaboxes[ilvl][key]], []
            )

            self.assertEqual(expected[ilvl], level_ghost_area_boxes)
コード例 #2
0
    def test_particle_ghost_area_boxes(self):
        print("GeometryTest.test_particle_ghost_area_boxes")
        hierarchy = super().basic_hierarchy()

        expected = {
            0: [
                {
                    "boxes": [
                        Box([-1, -1], [-1, 10]),
                        Box([10, -1], [10, 10]),
                        Box([0, -1], [9, -1]),
                        Box([0, 10], [9, 10]),
                    ]
                },
                {
                    "boxes": [
                        Box([9, 9], [9, 20]),
                        Box([20, 9], [20, 20]),
                        Box([10, 9], [19, 9]),
                        Box([10, 20], [19, 20]),
                    ]
                },
                {
                    "boxes": [
                        Box([-1, 9], [-1, 20]),
                        Box([10, 9], [10, 20]),
                        Box([0, 9], [9, 9]),
                        Box([0, 20], [9, 20]),
                    ]
                },
                {
                    "boxes": [
                        Box([9, -1], [9, 10]),
                        Box([20, -1], [20, 10]),
                        Box([10, -1], [19, -1]),
                        Box([10, 10], [19, 10]),
                    ]
                },
            ],
            1: [
                {
                    "boxes": [
                        Box([9, 9], [9, 20]),
                        Box([20, 9], [20, 20]),
                        Box([10, 9], [19, 9]),
                        Box([10, 20], [19, 20]),
                    ]
                },
                {
                    "boxes": [
                        Box([27, 27], [27, 40]),
                        Box([40, 27], [40, 40]),
                        Box([28, 27], [39, 27]),
                        Box([28, 40], [39, 40]),
                    ]
                },
            ],
        }

        gaboxes = ghost_area_boxes(hierarchy, "particles")
        particles = "particles"

        self.assertEqual(len(expected), len(gaboxes))

        for ilvl, lvl in enumerate(hierarchy.patch_levels):
            self.assertEqual(len(gaboxes[ilvl][particles]),
                             len(expected[ilvl]))
            for act_pdata, exp_pdata in zip(gaboxes[ilvl][particles],
                                            expected[ilvl]):
                self.assertEqual(len(exp_pdata["boxes"]),
                                 len(act_pdata["boxes"]))
                for exp_box in exp_pdata["boxes"]:
                    self.assertTrue(exp_box in act_pdata["boxes"])