Example #1
0
    def test_scalar_1d(self, data, halo, side):
        # arrange
        field = ScalarField(data, halo, (PeriodicBoundaryCondition(),))
        meta_and_data, fill_halos = field.impl
        traversals = Traversals(grid=data.shape, halo=halo, jit_flags={})
        sut, _ = traversals.make_boundary_conditions()

        # act
        sut(*meta_and_data, *fill_halos)

        # assert
        if side == LEFT:
            np.testing.assert_array_equal(field.data[:halo], data[-halo:])
        elif side == RIGHT:
            np.testing.assert_array_equal(field.data[-halo:], data[:halo])
        else:
            raise ValueError()
Example #2
0
    def test_vector_1d(self, data, halo, side):
        # arrange
        field = VectorField((data,), halo, (PeriodicBoundaryCondition(),))
        meta_and_data, fill_halos = field.impl
        traversals = Traversals(grid=(data.shape[0]-1,), halo=halo, jit_flags={})
        _, sut = traversals.make_boundary_conditions()

        # act
        sut(*meta_and_data, *fill_halos)

        # assert
        if halo == 1:
            return
        print(field.data)
        if side == LEFT:
            np.testing.assert_array_equal(field.data[0][:(halo-1)], data[-(halo-1):])
        elif side == RIGHT:
            np.testing.assert_array_equal(field.data[0][-(halo-1):], data[:(halo-1)])
        else:
            raise ValueError()