diff --git a/input.py b/input.py index 204fcba9436c46f219d05a67fac0619312a92560..2f9b86fa59999dd0cff9921f09827e6cfcc4c847 100644 --- a/input.py +++ b/input.py @@ -18,6 +18,7 @@ class FluxDataSingle: self.state_pair = u.transposed_array_from_string(states_str) self.states = u.expand_to_6(self.state_pair) self.flux_pair = u.transposed_array_from_string(fluxes_str) + self.fluxes = u.expand_to_6(self.flux_pair) self.lam_pointwise = u.expand_to_6( u.transposed_array_from_string(lam_str)) diff --git a/test.py b/test.py index 879b26d88b84f7708bd62342fc6b6f0dbd309580..16dc18aff022881b150b2386164a6795bd50f0ad 100644 --- a/test.py +++ b/test.py @@ -235,72 +235,23 @@ def test_weno_weights_neg_uniform_grid( u.compare_arrays(weights_dev.get(), weights_expected) -@pytest.mark.parametrize(("states_str,fluxes_str,R_inv_str,wavespeeds_str," - "fluxes_pos_expected_str,fluxes_neg_expected_str"), [ - ("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", - ("0.367521364 0.265894836 0.265894836 0.265894836 -0.167673798," - "-1.12132034 0 0.707106781 0 0," - "-1.12132034 0 0 0.707106781 0," - "-0.430558632 0.416709665 -0.290397116 -0.290397116 0.183124984," - "1.81208206 -0.997503897 -0.290397116 -0.290397116 0.183124984"), - "2.2 2.2 2.2 3.84632925 0.55367075", - ("1.09071563 1.23015152 1.23015152 7.52305259 0.232956271," - "0.467376796 -0.6627417 -0.6627417 1.47953026 0.312527304"), - ("-0.168354897 -0.0585786438 -0.0585786438 -0.727493464 -0.306026299," - "-0.0672231577 0.248528137 0.248528137 -0.107250611 -0.374562227")), - ("1 -1 -1 -1 5.5,2 -4 -4 -4 20", "-1 2.6 1 1 -7.1,-4 11.2 8 8 -46.4", - ("0.367521364 -0.265894836 -0.265894836 -0.265894836 -0.167673798," - "1.12132034 0 0.707106781 0 0," - "1.12132034 0 0 0.707106781 0," - "1.81208206 0.997503897 0.290397116 0.290397116 0.183124984," - "-0.430558632 -0.416709665 0.290397116 0.290397116 0.183124984"), - "2.2 2.2 2.2 0.55367075 3.84632925", - ("0.0672231577 0.248528137 0.248528137 0.374562227 0.107250611," - "0.168354897 -0.0585786438 -0.0585786438 0.306026299 0.727493464"), - ("-0.467376796 -0.6627417 -0.6627417 -0.312527304 -1.47953026," - "-1.09071563 1.23015152 1.23015152 -0.232956271 -7.52305259")), - ("2 4 8 12 64,1 1 2 3 11", "4 11.2 16 24 134.4,1 2.6 2 3 12.6", - ("-1.41187463 0.217276117 0.434552233 0.65182835 -0.13701474," - "-2.24264069 0 0.707106781 0 0," - "-3.36396103 0 0 0.707106781 0," - "1.79265641 0.444598298 -0.525016967 -0.78752545 0.165538358," - "4.03529709 -0.969615265 -0.525016967 -0.78752545 0.165538358"), - "2.2 2.2 2.2 3.84632925 0.55367075", - ("1.1162114 2.46030304 3.69045456 7.98692488 0.429010898," - "0.260735274 -1.3254834 -1.9882251 2.05242289 0.501788756"), - ("-0.148282372 -0.117157288 -0.175735931 -0.889325254 -0.200040418," - "-0.00948821371 0.497056275 0.745584412 -0.430637881 -0.314318322")), - ]) -def test_flux_splitting_uniform_grid( - ctx_factory, states_str, fluxes_str, R_inv_str, wavespeeds_str, - fluxes_pos_expected_str, fluxes_neg_expected_str): +def test_flux_splitting_uniform_grid(ctx_factory, data): prg = u.get_weno_program_with_root_kernel("split_characteristic_fluxes") queue = u.get_queue(ctx_factory) - nvars = 5 - - states = u.expand_to_6(u.transposed_array_from_string(states_str)) - fluxes = u.expand_to_6(u.transposed_array_from_string(fluxes_str)) - R_inv = u.array_from_string(R_inv_str) - wavespeeds = u.array_from_string(wavespeeds_str) - fluxes_pos_dev = u.empty_array_on_device(queue, nvars, 6) - fluxes_neg_dev = u.empty_array_on_device(queue, nvars, 6) + fluxes_pos_dev = u.empty_array_on_device(queue, data.nvars, 6) + fluxes_neg_dev = u.empty_array_on_device(queue, data.nvars, 6) - prg(queue, nvars=nvars, - generalized_states_frozen=states, - generalized_fluxes_frozen=fluxes, - R_inv=R_inv, - wavespeeds=wavespeeds, + prg(queue, nvars=data.nvars, + generalized_states_frozen=data.states, + generalized_fluxes_frozen=data.fluxes, + R_inv=data.R_inv, + wavespeeds=data.wavespeeds, characteristic_fluxes_pos=fluxes_pos_dev, characteristic_fluxes_neg=fluxes_neg_dev) - fluxes_pos_expected = u.expand_to_6( - u.transposed_array_from_string(fluxes_pos_expected_str)) - u.compare_arrays(fluxes_pos_dev.get(), fluxes_pos_expected) - - fluxes_neg_expected = u.expand_to_6( - u.transposed_array_from_string(fluxes_neg_expected_str)) - u.compare_arrays(fluxes_neg_dev.get(), fluxes_neg_expected) + u.compare_arrays(fluxes_pos_dev.get(), data.char_fluxes_pos) + u.compare_arrays(fluxes_neg_dev.get(), data.char_fluxes_neg) def test_pointwise_eigenvalues_ideal_gas(ctx_factory, data):