From 086332ce992ebda3492846c83320f3869dc35876 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Tue, 9 Jul 2019 19:47:59 -0500 Subject: [PATCH 1/7] added test for consistent part of WENO flux --- test.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test.py b/test.py index 8c58b09..a512a8e 100644 --- a/test.py +++ b/test.py @@ -74,6 +74,31 @@ def test_weno_flux_uniform_grid( u.compare_arrays(flux_dev.get(), flux_expected) +@pytest.mark.parametrize(("gen_fluxes_str,consistent_expected_str"), [ + ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", + "2.5 6.9 4.5 4.5 26.75"), + ("-1 2.6 1 1 -7.1,-4 11.2 8 8 -46.4", + "-2.5 6.9 4.5 4.5 -26.75") + ]) +def test_consistent_part_uniform_grid( + ctx_factory, gen_fluxes_str, consistent_expected_str): + prg = u.get_weno_program_with_root_kernel("consistent_part") + queue = u.get_queue(ctx_factory) + + nvars = 5 + + gen_fluxes = u.expand_to_6( + u.transposed_array_from_string(gen_fluxes_str)) + consistent_dev = u.empty_array_on_device(queue, nvars) + + prg(queue, nvars=nvars, + generalized_fluxes=gen_fluxes, + consistent=consistent_dev) + + consistent_expected = u.array_from_string(consistent_expected_str) + u.compare_arrays(consistent_dev.get(), consistent_expected) + + @pytest.mark.slow @pytest.mark.parametrize(("states_str,fluxes_str,R_inv_str,wavespeeds_str," "fluxes_pos_expected_str,fluxes_neg_expected_str"), [ -- GitLab From d5f4d01bba36f5436eadd4793bbd64aae962e39f Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Tue, 9 Jul 2019 19:49:24 -0500 Subject: [PATCH 2/7] consistent_part test is expected to fail --- test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test.py b/test.py index a512a8e..7de4983 100644 --- a/test.py +++ b/test.py @@ -74,6 +74,7 @@ def test_weno_flux_uniform_grid( u.compare_arrays(flux_dev.get(), flux_expected) +@pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,consistent_expected_str"), [ ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", "2.5 6.9 4.5 4.5 26.75"), -- GitLab From 7950a4048b7d4cda1c5fd4aebcab508aba663a51 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Tue, 9 Jul 2019 19:55:40 -0500 Subject: [PATCH 3/7] bugfix: consistent_part was off by factor of 60 --- WENO.F90 | 1 + test.py | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/WENO.F90 b/WENO.F90 index f829dfe..200d3a9 100644 --- a/WENO.F90 +++ b/WENO.F90 @@ -688,6 +688,7 @@ subroutine consistent_part(nvars, generalized_fluxes, consistent) consistent(v) = generalized_fluxes(v,-2) - 8*generalized_fluxes(v,-1) & + 37*generalized_fluxes(v,0) + 37*generalized_fluxes(v,1) & - 8*generalized_fluxes(v,2) + generalized_fluxes(v,3) + consistent(v) = consistent(v)/60.0 end do end subroutine diff --git a/test.py b/test.py index 7de4983..82404c8 100644 --- a/test.py +++ b/test.py @@ -17,7 +17,6 @@ from pyopencl.tools import ( # noqa import utilities as u -@pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,char_fluxes_pos_str,char_fluxes_neg_str," "combined_metric,R_str,flux_expected_str"), [ ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", @@ -74,7 +73,6 @@ def test_weno_flux_uniform_grid( u.compare_arrays(flux_dev.get(), flux_expected) -@pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,consistent_expected_str"), [ ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", "2.5 6.9 4.5 4.5 26.75"), -- GitLab From 47f4f03604636b49be6a6d83b30ac9d67b7f8678 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Tue, 9 Jul 2019 19:57:40 -0500 Subject: [PATCH 4/7] fix some indentation to (hopefully) make flake8 happy --- test.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index 7de4983..79b1b7c 100644 --- a/test.py +++ b/test.py @@ -44,7 +44,7 @@ import utilities as u "-1.58578644 0 1.41421356 -0.725992789 -0.725992789," "3.77207794 -2.24264069 -2.24264069 3.3359596 5.57860029"), "-4.35371022 12.2479485 8.99522344 8.99522344 -51.3903927") - ]) + ]) def test_weno_flux_uniform_grid( ctx_factory, gen_fluxes_str, char_fluxes_pos_str, char_fluxes_neg_str, combined_metric, R_str, flux_expected_str): @@ -76,10 +76,10 @@ def test_weno_flux_uniform_grid( @pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,consistent_expected_str"), [ - ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", - "2.5 6.9 4.5 4.5 26.75"), - ("-1 2.6 1 1 -7.1,-4 11.2 8 8 -46.4", - "-2.5 6.9 4.5 4.5 -26.75") + ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", + "2.5 6.9 4.5 4.5 26.75"), + ("-1 2.6 1 1 -7.1,-4 11.2 8 8 -46.4", + "-2.5 6.9 4.5 4.5 -26.75") ]) def test_consistent_part_uniform_grid( ctx_factory, gen_fluxes_str, consistent_expected_str): -- GitLab From 77515653617df775bc134b5d6a1debf152603e38 Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Mon, 15 Jul 2019 10:13:20 -0500 Subject: [PATCH 5/7] added tests for dissipation part --- test.py | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test.py b/test.py index 56c8179..fde5322 100644 --- a/test.py +++ b/test.py @@ -98,6 +98,94 @@ def test_consistent_part_uniform_grid( u.compare_arrays(consistent_dev.get(), consistent_expected) +@pytest.mark.parametrize(("char_fluxes_str,combined_metric," + "R_str,dissipation_expected_str"), [ + (("1.09071563 1.23015152 1.23015152 7.52305259 0.232956271," + "0.467376796 -0.6627417 -0.6627417 1.47953026 0.312527304"), + 1.0, + ("1 0 0 0.45781246 0.45781246," + "1.58578644 0 0 1.43309957 0.0188860081," + "1.58578644 1.41421356 0 0.725992789 0.725992789," + "1.58578644 0 1.41421356 0.725992789 0.725992789," + "3.77207794 2.24264069 2.24264069 5.57860029 3.3359596"), + "1.67685514 4.82397437 3.99761177 3.99761177 22.1451964"), + (("0.0672231577 0.248528137 0.248528137 0.374562227 0.107250611," + "0.168354897 -0.0585786438 -0.0585786438 0.306026299 0.727493464"), + 1.0, + ("1 0 0 0.45781246 0.45781246," + "-1.58578644 0 0 -0.0188860081 -1.43309957," + "-1.58578644 1.41421356 0 -0.725992789 -0.725992789," + "-1.58578644 0 1.41421356 -0.725992789 -0.725992789," + "3.77207794 -2.24264069 -2.24264069 3.3359596 5.57860029"), + "-0.17685508 0.523974175 0.497611669 0.497611669 -2.49519635") + ]) +def test_dissipation_part_pos_uniform_grid( + ctx_factory, char_fluxes_str, combined_metric, R_str, + dissipation_expected_str): + prg = u.get_weno_program_with_root_kernel("dissipation_part_pos") + queue = u.get_queue(ctx_factory) + + nvars = 5 + + char_fluxes = u.expand_to_6( + u.transposed_array_from_string(char_fluxes_str)) + R = u.array_from_string(R_str) + dissipation_dev = u.empty_array_on_device(queue, nvars) + + prg(queue, nvars=nvars, + characteristic_fluxes=char_fluxes, + combined_frozen_metrics=combined_metric, + R=R, + dissipation_pos=dissipation_dev) + + dissipation_expected = u.array_from_string(dissipation_expected_str) + u.compare_arrays(dissipation_dev.get(), dissipation_expected) + + +@pytest.mark.parametrize(("char_fluxes_str,combined_metric," + "R_str,dissipation_expected_str"), [ + (("-0.168354897 -0.0585786438 -0.0585786438 -0.727493464 -0.306026299," + "-0.0672231577 0.248528137 0.248528137 -0.107250611 -0.374562227"), + 1.0, + ("1 0 0 0.45781246 0.45781246," + "1.58578644 0 0 1.43309957 0.0188860081," + "1.58578644 1.41421356 0 0.725992789 0.725992789," + "1.58578644 0 1.41421356 0.725992789 0.725992789," + "3.77207794 2.24264069 2.24264069 5.57860029 3.3359596"), + "0.17685508 0.523974175 0.497611669 0.497611669 2.49519635"), + (("-0.467376796 -0.6627417 -0.6627417 -0.312527304 -1.47953026," + "-1.09071563 1.23015152 1.23015152 -0.232956271 -7.52305259"), + 1.0, + ("1 0 0 0.45781246 0.45781246," + "-1.58578644 0 0 -0.0188860081 -1.43309957," + "-1.58578644 1.41421356 0 -0.725992789 -0.725992789," + "-1.58578644 0 1.41421356 -0.725992789 -0.725992789," + "3.77207794 -2.24264069 -2.24264069 3.3359596 5.57860029"), + "-1.67685514 4.82397437 3.99761177 3.99761177 -22.1451964") + ]) +def test_dissipation_part_neg_uniform_grid( + ctx_factory, char_fluxes_str, combined_metric, R_str, + dissipation_expected_str): + prg = u.get_weno_program_with_root_kernel("dissipation_part_neg") + queue = u.get_queue(ctx_factory) + + nvars = 5 + + char_fluxes = u.expand_to_6( + u.transposed_array_from_string(char_fluxes_str)) + R = u.array_from_string(R_str) + dissipation_dev = u.empty_array_on_device(queue, nvars) + + prg(queue, nvars=nvars, + characteristic_fluxes=char_fluxes, + combined_frozen_metrics=combined_metric, + R=R, + dissipation_neg=dissipation_dev) + + dissipation_expected = u.array_from_string(dissipation_expected_str) + u.compare_arrays(dissipation_dev.get(), dissipation_expected) + + @pytest.mark.slow @pytest.mark.parametrize(("states_str,fluxes_str,R_inv_str,wavespeeds_str," "fluxes_pos_expected_str,fluxes_neg_expected_str"), [ -- GitLab From 97e90db56876b16cb3534910d390d05108b200ba Mon Sep 17 00:00:00 2001 From: "Timothy A. Smith" Date: Mon, 15 Jul 2019 10:18:37 -0500 Subject: [PATCH 6/7] mark failing tests --- test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test.py b/test.py index fde5322..878e48c 100644 --- a/test.py +++ b/test.py @@ -17,6 +17,7 @@ from pyopencl.tools import ( # noqa import utilities as u +@pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,char_fluxes_pos_str,char_fluxes_neg_str," "combined_metric,R_str,flux_expected_str"), [ ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", @@ -73,6 +74,7 @@ def test_weno_flux_uniform_grid( u.compare_arrays(flux_dev.get(), flux_expected) +@pytest.mark.xfail @pytest.mark.parametrize(("gen_fluxes_str,consistent_expected_str"), [ ("4 11.2 8 8 46.4,1 2.6 1 1 7.1", "2.5 6.9 4.5 4.5 26.75"), @@ -98,6 +100,7 @@ def test_consistent_part_uniform_grid( u.compare_arrays(consistent_dev.get(), consistent_expected) +@pytest.mark.xfail @pytest.mark.parametrize(("char_fluxes_str,combined_metric," "R_str,dissipation_expected_str"), [ (("1.09071563 1.23015152 1.23015152 7.52305259 0.232956271," @@ -142,6 +145,7 @@ def test_dissipation_part_pos_uniform_grid( u.compare_arrays(dissipation_dev.get(), dissipation_expected) +@pytest.mark.xfail @pytest.mark.parametrize(("char_fluxes_str,combined_metric," "R_str,dissipation_expected_str"), [ (("-0.168354897 -0.0585786438 -0.0585786438 -0.727493464 -0.306026299," -- GitLab From 903601588e1d1149d04de1ff28a8db10f9bd2882 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Wed, 17 Jul 2019 03:57:41 +0200 Subject: [PATCH 7/7] Revert "Merge branch 'dissipation-part-tests' into 'consistent-part-test'" This reverts merge request !22 --- WENO.F90 | 1 - test.py | 90 -------------------------------------------------------- 2 files changed, 91 deletions(-) diff --git a/WENO.F90 b/WENO.F90 index 200d3a9..f829dfe 100644 --- a/WENO.F90 +++ b/WENO.F90 @@ -688,7 +688,6 @@ subroutine consistent_part(nvars, generalized_fluxes, consistent) consistent(v) = generalized_fluxes(v,-2) - 8*generalized_fluxes(v,-1) & + 37*generalized_fluxes(v,0) + 37*generalized_fluxes(v,1) & - 8*generalized_fluxes(v,2) + generalized_fluxes(v,3) - consistent(v) = consistent(v)/60.0 end do end subroutine diff --git a/test.py b/test.py index 878e48c..79b1b7c 100644 --- a/test.py +++ b/test.py @@ -100,96 +100,6 @@ def test_consistent_part_uniform_grid( u.compare_arrays(consistent_dev.get(), consistent_expected) -@pytest.mark.xfail -@pytest.mark.parametrize(("char_fluxes_str,combined_metric," - "R_str,dissipation_expected_str"), [ - (("1.09071563 1.23015152 1.23015152 7.52305259 0.232956271," - "0.467376796 -0.6627417 -0.6627417 1.47953026 0.312527304"), - 1.0, - ("1 0 0 0.45781246 0.45781246," - "1.58578644 0 0 1.43309957 0.0188860081," - "1.58578644 1.41421356 0 0.725992789 0.725992789," - "1.58578644 0 1.41421356 0.725992789 0.725992789," - "3.77207794 2.24264069 2.24264069 5.57860029 3.3359596"), - "1.67685514 4.82397437 3.99761177 3.99761177 22.1451964"), - (("0.0672231577 0.248528137 0.248528137 0.374562227 0.107250611," - "0.168354897 -0.0585786438 -0.0585786438 0.306026299 0.727493464"), - 1.0, - ("1 0 0 0.45781246 0.45781246," - "-1.58578644 0 0 -0.0188860081 -1.43309957," - "-1.58578644 1.41421356 0 -0.725992789 -0.725992789," - "-1.58578644 0 1.41421356 -0.725992789 -0.725992789," - "3.77207794 -2.24264069 -2.24264069 3.3359596 5.57860029"), - "-0.17685508 0.523974175 0.497611669 0.497611669 -2.49519635") - ]) -def test_dissipation_part_pos_uniform_grid( - ctx_factory, char_fluxes_str, combined_metric, R_str, - dissipation_expected_str): - prg = u.get_weno_program_with_root_kernel("dissipation_part_pos") - queue = u.get_queue(ctx_factory) - - nvars = 5 - - char_fluxes = u.expand_to_6( - u.transposed_array_from_string(char_fluxes_str)) - R = u.array_from_string(R_str) - dissipation_dev = u.empty_array_on_device(queue, nvars) - - prg(queue, nvars=nvars, - characteristic_fluxes=char_fluxes, - combined_frozen_metrics=combined_metric, - R=R, - dissipation_pos=dissipation_dev) - - dissipation_expected = u.array_from_string(dissipation_expected_str) - u.compare_arrays(dissipation_dev.get(), dissipation_expected) - - -@pytest.mark.xfail -@pytest.mark.parametrize(("char_fluxes_str,combined_metric," - "R_str,dissipation_expected_str"), [ - (("-0.168354897 -0.0585786438 -0.0585786438 -0.727493464 -0.306026299," - "-0.0672231577 0.248528137 0.248528137 -0.107250611 -0.374562227"), - 1.0, - ("1 0 0 0.45781246 0.45781246," - "1.58578644 0 0 1.43309957 0.0188860081," - "1.58578644 1.41421356 0 0.725992789 0.725992789," - "1.58578644 0 1.41421356 0.725992789 0.725992789," - "3.77207794 2.24264069 2.24264069 5.57860029 3.3359596"), - "0.17685508 0.523974175 0.497611669 0.497611669 2.49519635"), - (("-0.467376796 -0.6627417 -0.6627417 -0.312527304 -1.47953026," - "-1.09071563 1.23015152 1.23015152 -0.232956271 -7.52305259"), - 1.0, - ("1 0 0 0.45781246 0.45781246," - "-1.58578644 0 0 -0.0188860081 -1.43309957," - "-1.58578644 1.41421356 0 -0.725992789 -0.725992789," - "-1.58578644 0 1.41421356 -0.725992789 -0.725992789," - "3.77207794 -2.24264069 -2.24264069 3.3359596 5.57860029"), - "-1.67685514 4.82397437 3.99761177 3.99761177 -22.1451964") - ]) -def test_dissipation_part_neg_uniform_grid( - ctx_factory, char_fluxes_str, combined_metric, R_str, - dissipation_expected_str): - prg = u.get_weno_program_with_root_kernel("dissipation_part_neg") - queue = u.get_queue(ctx_factory) - - nvars = 5 - - char_fluxes = u.expand_to_6( - u.transposed_array_from_string(char_fluxes_str)) - R = u.array_from_string(R_str) - dissipation_dev = u.empty_array_on_device(queue, nvars) - - prg(queue, nvars=nvars, - characteristic_fluxes=char_fluxes, - combined_frozen_metrics=combined_metric, - R=R, - dissipation_neg=dissipation_dev) - - dissipation_expected = u.array_from_string(dissipation_expected_str) - u.compare_arrays(dissipation_dev.get(), dissipation_expected) - - @pytest.mark.slow @pytest.mark.parametrize(("states_str,fluxes_str,R_inv_str,wavespeeds_str," "fluxes_pos_expected_str,fluxes_neg_expected_str"), [ -- GitLab