From 1efc7f701a37e59e1f7130d01d21503f48f028b5 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Wed, 26 Jun 2019 12:35:06 -0500 Subject: [PATCH] added test for pointwise-eigenvalues --- test.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test.py b/test.py index 97ccfe7..ce10501 100644 --- a/test.py +++ b/test.py @@ -18,6 +18,53 @@ from pyopencl.tools import ( # noqa from utilities import * +@pytest.mark.parametrize("states_str,direction,lam_expected_str", [ + ("2 4 4 4 20,1 1 1 1 5.5", "x", + "2 2 2 3.49666295 0.503337045,1 1 1 2.49666295 -0.496662955"), + ("2 4 4 4 20,1 1 1 1 5.5", "y", + "2 2 2 3.49666295 0.503337045,1 1 1 2.49666295 -0.496662955"), + ("2 4 4 4 20,1 1 1 1 5.5", "z", + "2 2 2 3.49666295 0.503337045,1 1 1 2.49666295 -0.496662955"), + ("1 -1 -1 -1 5.5,2 -4 -4 -4 20", "x", + "-1 -1 -1 0.496662955 -2.49666295,-2 -2 -2 -0.503337045 -3.49666295"), + ("1 -1 -1 -1 5.5,2 -4 -4 -4 20", "y", + "-1 -1 -1 0.496662955 -2.49666295,-2 -2 -2 -0.503337045 -3.49666295"), + ("1 -1 -1 -1 5.5,2 -4 -4 -4 20", "z", + "-1 -1 -1 0.496662955 -2.49666295,-2 -2 -2 -0.503337045 -3.49666295"), + ("2 4 8 12 64,1 1 2 3 11", "x", + "2 2 2 3.49666295 0.503337045,1 1 1 2.49666295 -0.496662955"), + ("2 4 8 12 64,1 1 2 3 11", "y", + "4 4 4 5.49666295 2.50333705,2 2 2 3.49666295 0.503337045"), + ("2 4 8 12 64,1 1 2 3 11", "z", + "6 6 6 7.49666295 4.50333705,3 3 3 4.49666295 1.503337045"), + ("1 -1 -2 -3 11,2 -4 -8 -12 64", "x", + "-1 -1 -1 0.496662955 -2.49666295,-2 -2 -2 -0.503337045 -3.49666295"), + ("1 -1 -2 -3 11,2 -4 -8 -12 64", "y", + "-2 -2 -2 -0.503337045 -3.49666295,-4 -4 -4 -2.50333705 -5.49666295"), + ("1 -1 -2 -3 11,2 -4 -8 -12 64", "z", + "-3 -3 -3 -1.50333705 -4.49666295,-6 -6 -6 -4.50333705 -7.49666295") + ]) +def test_pointwise_eigenvalues( + ctx_factory, states_str, direction, lam_expected_str): + def expand_to_6(pair): + return np.repeat(pair, 3, axis=1).copy(order="F") + + prg = get_weno_program_with_root_kernel("pointwise_eigenvalues") + queue = get_queue(ctx_factory) + + nvars = 5 + dirs = {"x" : 1, "y" : 2, "z" : 3} + + states = expand_to_6(transposed_array_from_string(states_str)) + lam_dev = empty_array_on_device(queue, nvars, 6) + + prg(queue, nvars=nvars, d=dirs[direction], + states=states, lambda_pointwise=lam_dev) + + lam_expected = expand_to_6(transposed_array_from_string(lam_expected_str)) + compare_arrays(lam_dev.get(), lam_expected) + + @pytest.mark.parametrize("states_str,fluxes_str,direction", [ ("2 4 4 4 20,1 1 1 1 5.5", "4 11.2 8 8 46.4,1 2.6 1 1 7.1", "x"), ("2 4 4 4 20,1 1 1 1 5.5", "4 8 11.2 8 46.4,1 1 2.6 1 7.1", "y"), -- GitLab