Beispiel #1
0
def compute_helper(now, padded, half_width, side_index, coeffs, smoothness, weights, eps):
    cells = len(now)
    weights = weights[:, side_index]
    coeffs = coeffs[:, side_index]
    beta = ext_weno.mult_with_smoothness(cells, half_width,
                                         padded, smoothness)
    s_weights = ext_weno.scaled_weights(cells, half_width,
                                        eps, weights, beta)
    small_polynomials = ext_weno.mult_with_coeffs(cells, half_width,
                                                  padded, coeffs)
    reconstruction = ext_weno.mult_polynomials(cells, half_width,
                                               s_weights, small_polynomials)
    return np.array(reconstruction)
Beispiel #2
0
def test_mult_with_smoothness():
    # test with the uniform smoothness coefficients in
    # Shu 2009
    now_chunk = np.array([1.0, 2.0, 3.0, 4.0, 6.0])
    smoothness = \
        np.array([[[[  3.33333333, -10.33333333,   3.66666667],
         [  0.        ,   8.33333333,  -6.33333333],
         [  0.        ,   0.        ,   1.33333333]],
        [[  1.33333333,  -4.33333333,   1.66666667],
         [  0.        ,   4.33333333,  -4.33333333],
         [  0.        ,   0.        ,   1.33333333]],
        [[  1.33333333,  -6.33333333,   3.66666667],
         [  0.        ,   8.33333333, -10.33333333],
         [  0.        ,   0.        ,   3.33333333]]]])
    correct = \
        13.0 / 12.0 * np.array([[0.0, 0.0, 1.0]]) ** 2 + \
        1.0 / 4.0 * np.array([[2.0, -2.0, -1.0]]) ** 2
    beta = ext_weno.mult_with_smoothness(1, 3, now_chunk, smoothness)
    np.testing.assert_almost_equal(beta, correct)