From fef702ec550f25f5e48cd8476f7ae3bcd9299384 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" <tasmith4@illinois.edu> Date: Sat, 20 Jul 2019 17:20:36 -0500 Subject: [PATCH] added new test for negative direction WENO weights, increase tolerance as necessary --- test.py | 38 +++++++++++++++++++++++++++++--------- utilities.py | 2 +- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/test.py b/test.py index 4311695..2167109 100644 --- a/test.py +++ b/test.py @@ -153,15 +153,7 @@ def test_dissipation_part_pos_uniform_grid( "2.23542587e-9 2.62886024e-11 2.62886024e-11 2.52995663e-13 " "8.39888392e-6," "1.78838212e-10 2.10309347e-12 2.10309347e-12 2.0239658e-14 " - "6.7286569e-7")), - #(("0.0672231577 0.248528137 0.248528137 0.374562227 0.107250611," - # "0.168354897 -0.0585786438 -0.0585786438 0.306026299 0.727493464"), - # 1.0, - # ("0.99999652 0.999999959 0.999999959 0.99998353 0.999999998," - # "3.22170414e-6 3.79356095e-8 3.79356095e-8 0.0000152478162 " - # "2.28039336e-9," - # "2.57963115e-7 3.03513836e-9 3.03513836e-9 1.22216217e-6 " - # "1.82435737e-10")) + "6.7286569e-7")) ]) def test_weno_weights_pos_uniform_grid( ctx_factory, char_fluxes_str, combined_metric, weights_expected_str): @@ -228,6 +220,34 @@ def test_dissipation_part_neg_uniform_grid( u.compare_arrays(dissipation_dev.get(), dissipation_expected) +@pytest.mark.parametrize(("char_fluxes_str,combined_metric,weights_expected_str"), [ + (("-0.168354897 -0.0585786438 -0.0585786438 -0.727493464 -0.306026299," + "-0.0672231577 0.248528137 0.248528137 -0.107250611 -0.374562227"), + 1.0, + ("0.99999652 0.999999959 0.999999959 0.999999998 0.99998353," + "3.22170414e-6 3.79356095e-8 3.79356095e-8 2.28039336e-9 0.0000152478162," + "2.57963115e-7 3.03513836e-9 3.03513836e-9 1.82435737e-10 1.22216217e-6")) + ]) +def test_weno_weights_neg_uniform_grid( + ctx_factory, char_fluxes_str, combined_metric, weights_expected_str): + prg = u.get_weno_program_with_root_kernel("weno_weights_neg") + queue = u.get_queue(ctx_factory) + + nvars = 5 + + char_fluxes = u.expand_to_6( + u.transposed_array_from_string(char_fluxes_str)) + weights_dev = u.empty_array_on_device(queue, nvars, 3) + + prg(queue, nvars=nvars, + characteristic_fluxes=char_fluxes, + combined_frozen_metrics=combined_metric, + w=weights_dev) + + weights_expected = u.transposed_array_from_string(weights_expected_str) + u.compare_arrays(weights_dev.get(), weights_expected) + + @pytest.mark.slow @pytest.mark.parametrize(("states_str,fluxes_str,R_inv_str,wavespeeds_str," "fluxes_pos_expected_str,fluxes_neg_expected_str"), [ diff --git a/utilities.py b/utilities.py index f7579ef..129680a 100644 --- a/utilities.py +++ b/utilities.py @@ -11,7 +11,7 @@ from pytest import approx # {{{ arrays def compare_arrays(a, b): - assert a == approx(b, rel=1e-5, abs=1e-5) + assert a == approx(b, rel=1e-5, abs=2e-5) def random_array_on_device(queue, *shape): -- GitLab