Ejemplo n.º 1
0
def ex2(N, hk, x0=1, y0=1, z0=1):
    r"""
    Compute the integral of :math:`1_{x/x0+y/y0+z/z0<= 1}`
    :math:`0< x0\leq 1` and :math:`0< y0\leq 1` and :math:`0< z0\leq 1`

    Parameters
    ----------
    N : int
        Order of base quadrature rule
    hk : double
         submesh element diameter
    x0 : integrand parameter
    y0 : integrand parameter
    z0 : integrand parameter
    """

    quad = Quadrature.GaussTetrahedron(N)
    comp_quad = Quadrature.CompositeTetrahedron(quad, hk)

    ii = np.sum(comp_quad.weights[np.less_equal(
        old_div(comp_quad.points[:, 0], x0) +
        old_div(comp_quad.points[:, 1], y0) +
        old_div(+comp_quad.points[:, 2], z0), 1.0)])

    ee = np.abs(ii - x0 * y0 * z0 / 6.0)

    logEvent("hk=%f\t true-int=%f\t comp-int=%f error=%f" %
             (comp_quad.h, x0 * y0 * z0 / 6.0, ii, ee))
    return comp_quad.h, ee
Ejemplo n.º 2
0
def ex4(N, hk):
    r"""
    Compute the integral of :math:`x` over the reference triangle

    Parameters
    ----------
    N : int
        Order of base quadrature rule
    hk : double
         submesh element diameter
    """

    quad = Quadrature.GaussTetrahedron(N)
    comp_quad = Quadrature.CompositeTetrahedron(quad, hk)

    quad_points = np.asarray(quad.points, 'd')
    quad_weights = np.asarray(quad.weights, 'd')

    ii_quad = np.sum(quad_weights * quad_points[:, 0])
    ii_comp_quad = np.sum(comp_quad.weights * comp_quad.points[:, 0])

    ee = np.abs(ii_quad - ii_comp_quad)
    logEvent("hk=%f\t quad-int=%f\t comp-quad-int=%f error=%f" %
             (comp_quad.h, ii_quad, ii_comp_quad, ee))
    return comp_quad.h, ee
Ejemplo n.º 3
0
def ex3(N, hk, r0):
    r"""
    Compute the integral of  :math:`1_{|[x,y,z]|<= r0}`
    :math: `r0<=0.5*sqrt(2)`

    Parameters
    ----------
    N : int
        Order of base quadrature rule
    hk : double
         submesh element diameter
    r0 : integrand parameter
    """

    quad = Quadrature.GaussTetrahedron(N)
    comp_quad = Quadrature.CompositeTetrahedron(quad, hk)

    ii = np.sum(comp_quad.weights[np.less_equal(
        comp_quad.points[:, 0] ** 2 + comp_quad.points[:, 1] ** 2 + comp_quad.points[:, 2] ** 2, r0 * r0)])
    ee = np.abs(ii - r0**3 * np.pi / 6.0)
    logEvent("hk=%f\t true-int=%f\t comp-int=%f error=%f" %
             (comp_quad.h, r0**3 * np.pi / 6.0, ii, ee))
    return comp_quad.h, ee