Ejemplo n.º 1
0
def test_improved_hypersingular():
    mesh = simple_line_mesh(1, (0, 0), (1, 0))
    mapping = PolynomialMapping(mesh.elements[0])
    degree = 7
    bf = gll_basis(degree)
    one = ConstantBasis(np.ones(2))

    quad_info_exact = gauss(100)

    a = 0.01
    b = 0.05

    mapped_ay = map_singular_pt(a, 0.0, 1.0)
    mapped_by = map_distance_to_interval(b, 0.0, 1.0)
    quad_deg = degree + 4

    moments_xa0_r0 = legendre.legendre_integrals(quad_deg)
    moments_xa0_r2 = modify_divide_r2(
        quad_deg, moments_xa0_r0, mapped_ay, mapped_by, mu_2_0(mapped_ay, mapped_by), mu_2_1(mapped_ay, mapped_by)
    )
    moments_xa0_r4 = modify_divide_r2(
        quad_deg, moments_xa0_r2, mapped_ay, mapped_by, mu_4_0(mapped_ay, mapped_by), mu_4_1(mapped_ay, mapped_by)
    )
    moments_xa0_r6 = modify_divide_r2(
        quad_deg, moments_xa0_r4, mapped_ay, mapped_by, mu_6_0(mapped_ay, mapped_by), mu_6_1(mapped_ay, mapped_by)
    )
    moments_xa1_r6 = modify_times_x_minus_a(len(moments_xa0_r6) - 2, moments_xa0_r6, mapped_ay)
    moments_xa2_r6 = modify_times_x_minus_a(len(moments_xa1_r6) - 2, moments_xa1_r6, mapped_ay)
    moments_xa3_r6 = modify_times_x_minus_a(len(moments_xa2_r6) - 2, moments_xa2_r6, mapped_ay)
    moments_xa4_r6 = modify_times_x_minus_a(len(moments_xa3_r6) - 2, moments_xa3_r6, mapped_ay)

    est = [[0, 0], [0, 0]]
    x, w = recursive_quad(moments_xa0_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 2)
    est[1][1] = w[0]

    x, w = recursive_quad(moments_xa1_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 1)
    est[0][1] = w[0]
    est[1][0] = w[0]
    x, w = recursive_quad(moments_xa2_r6[: degree + 1])
    x, w = map_pts_wts(x, w, 0.0, 1.0)
    w = map_weights_by_inv_power(w, 6.0, 0.0, 1.0) * ((-b / 2) ** 2) * ((-2 * b) ** 0)
    est[0][0] = w[0]

    # qi = QuadratureInfo(a, x, w)

    kernelv1 = HypersingularPart1V1()
    kernelv2 = HypersingularPart1V2()

    pt = [a, b]
    normal = [0.0, 1.0]
    kernelv1.set_interior_data(pt, normal)
    kernelv2.set_interior_data(pt, normal)

    integrate = lambda qi, k: single_integral(mapping.eval, k, one, bf, qi, 0, 0)
    exact = integrate(quad_info_exact, kernelv1)
    np.testing.assert_almost_equal(np.array(exact), np.array(est), 10)
Ejemplo n.º 2
0
def rl_quad(N, ay, by):
    mapped_ay = qc.map_singular_pt(ay, 0.0, 1.0)
    mapped_by = qc.map_distance_to_interval(by, 0.0, 1.0)
    moments = qc.modified_moments(qc.rl1, N - 1, mapped_ay, mapped_by)
    x, w = qc.recursive_quad(moments)
    x, w = qc.map_pts_wts(x, w, 0.0, 1.0)
    w = qc.map_weights_by_inv_power(w, 1.0, 0.0, 1.0)

    # Fix this
    new_w = w * ((x - ay) ** 2 + by ** 2) ** (1.0 / 2.0)
    return QuadratureInfo(ay, x, new_w)
Ejemplo n.º 3
0
def telles_quasi_singular(N, x0, D):
    # I think D needs to be mapped into local coords too
    mapped_x0 = qc.map_singular_pt(x0, 0.0, 1.0)
    x, w = qc.telles_quasi_singular(N, mapped_x0, D)
    x, w = qc.map_pts_wts(x, w, 0.0, 1.0)
    return QuadratureInfo(x0, x, w)
Ejemplo n.º 4
0
def telles_singular(N, x0):
    mapped_x0 = qc.map_singular_pt(x0, 0.0, 1.0)
    x, w = qc.telles_singular(N, mapped_x0)
    x, w = qc.map_pts_wts(x, w, 0.0, 1.0)
    return QuadratureInfo(x0, x, w)
Ejemplo n.º 5
0
def piessens(N, x0, nonsingular_N):
    mapped_x0 = qc.map_singular_pt(x0, 0.0, 1.0)
    x, w = qc.piessens(N, mapped_x0, nonsingular_N = nonsingular_N)
    x, w = qc.map_pts_wts(x, w, 0.0, 1.0)
    return QuadratureInfo(x0, x, w)