Skip to content
Snippets Groups Projects
Commit 23a45444 authored by Timothy A. Smith's avatar Timothy A. Smith
Browse files

introduce new test to check whether bug is in WENO.F90 or Mathematica script

parent 14bdf2b4
No related branches found
No related tags found
1 merge request!33Reference implementation
......@@ -24,6 +24,49 @@ from data_for_test import ( # noqa: F401
def test_weno_weight_computation(ctx_factory, flux_test_data_fixture):
data = flux_test_data_fixture
def weno_weights(oscillation):
linear = np.array([0.1, 0.6, 0.3])
eps = 1e-6
raw_weights = np.empty((5,3))
for i in range(5):
for j in range(3):
raw_weights[i,j] = linear[j]/(oscillation[i,j] + eps)**2
weight_sum = raw_weights.sum(axis=1)
weights = np.empty((5,3))
for i in range(5):
for j in range(3):
weights[i,j] = raw_weights[i,j]/weight_sum[i]
return weights
prg = u.get_weno_program_with_root_kernel("weno_weights_pos")
queue = u.get_queue(ctx_factory)
weights_dev = u.empty_array_on_device(queue, data.nvars, 3)
prg(queue, nvars=data.nvars,
characteristic_fluxes=data.char_fluxes_pos,
combined_frozen_metrics=1.0,
w=weights_dev)
w = weno_weights(data.oscillation_pos)
u.compare_arrays(weights_dev.get(), w)
prg = u.get_weno_program_with_root_kernel("weno_weights_neg")
queue = u.get_queue(ctx_factory)
weights_dev = u.empty_array_on_device(queue, data.nvars, 3)
prg(queue, nvars=data.nvars,
characteristic_fluxes=data.char_fluxes_neg,
combined_frozen_metrics=1.0,
w=weights_dev)
w = weno_weights(data.oscillation_neg)
u.compare_arrays(weights_dev.get(), w)
def test_weno_flux_uniform_grid(ctx_factory, flux_test_data_fixture):
data = flux_test_data_fixture
......
......@@ -11,7 +11,8 @@ from pytest import approx
# {{{ arrays
def compare_arrays(a, b):
assert a == approx(b, rel=1e-5, abs=2e-5)
#assert a == approx(b, rel=1e-5, abs=2e-5)
assert a == approx(b, rel=1e-12, abs=1e-14)
def random_array_on_device(queue, *shape):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment