示例#1
0
def get_line_element(V):
    # Return the Line elements for Q, DQ, RTCF/E, NCF/E
    from FIAT.reference_element import UFCInterval
    from FIAT import gauss_legendre, gauss_lobatto_legendre, lagrange, discontinuous_lagrange
    use_tensorproduct, N, ndim, sub_families, variant = tensor_product_space_query(
        V)
    assert use_tensorproduct
    cell = UFCInterval()
    if sub_families <= {"Q", "Lagrange"}:
        if variant == "equispaced":
            element = lagrange.Lagrange(cell, N)
        else:
            element = gauss_lobatto_legendre.GaussLobattoLegendre(cell, N)
        element = [element] * ndim
    elif sub_families <= {"DQ", "Discontinuous Lagrange"}:
        if variant == "equispaced":
            element = discontinuous_lagrange.DiscontinuousLagrange(cell, N)
        else:
            element = gauss_legendre.GaussLegendre(cell, N)
        element = [element] * ndim
    elif sub_families < {"RTCF", "NCF"}:
        cg = gauss_lobatto_legendre.GaussLobattoLegendre(cell, N)
        dg = gauss_legendre.GaussLegendre(cell, N - 1)
        element = [cg] + [dg] * (ndim - 1)
    elif sub_families < {"RTCE", "NCE"}:
        cg = gauss_lobatto_legendre.GaussLobattoLegendre(cell, N)
        dg = gauss_legendre.GaussLegendre(cell, N - 1)
        element = [dg] + [cg] * (ndim - 1)
    else:
        raise ValueError("Don't know how to get line element for %s" %
                         V.ufl_element())
    return element
示例#2
0
def get_line_element(V):
    # Return the corresponding Line element for CG / DG
    from FIAT.reference_element import UFCInterval
    from FIAT import gauss_legendre, gauss_lobatto_legendre, lagrange, discontinuous_lagrange
    use_tensorproduct, N, family, variant = tensor_product_space_query(V)
    assert use_tensorproduct
    cell = UFCInterval()
    if family <= {"Q", "Lagrange"}:
        if variant == "equispaced":
            element = lagrange.Lagrange(cell, N)
        else:
            element = gauss_lobatto_legendre.GaussLobattoLegendre(cell, N)
    elif family <= {"DQ", "Discontinuous Lagrange"}:
        if variant == "equispaced":
            element = discontinuous_lagrange.DiscontinuousLagrange(cell, N)
        else:
            element = gauss_legendre.GaussLegendre(cell, N)
    else:
        raise ValueError("Don't know how to get line element for %r" % family)

    return element
示例#3
0
def BDFMSpace(ref_el, order):
    sd = ref_el.get_spatial_dimension()
    if sd != 2:
        raise Exception("BDFM_k elements only valid for dim 2")
    # Note that order will be 2.

    # Linear vector valued space. Since the embedding degree of this element
    # is 2, this is implemented by taking the quadratic space and selecting
    # the linear polynomials.
    vec_poly_set = polynomial_set.ONPolynomialSet(ref_el, order, (sd,))
    # Linears are the first three polynomials in each dimension.
    vec_poly_set = vec_poly_set.take([0, 1, 2, 6, 7, 8])

    # Scalar quadratic Lagrange element.
    lagrange_ele = lagrange.Lagrange(ref_el, order)
    # Select the dofs associated with the edges.
    edge_dofs_dict = lagrange_ele.dual.get_entity_ids()[sd - 1]
    edge_dofs = numpy.array([(edge, dof)
                             for edge, dofs in list(edge_dofs_dict.items())
                             for dof in dofs])

    tangent_polys = lagrange_ele.poly_set.take(edge_dofs[:, 1])
    new_coeffs = numpy.zeros((tangent_polys.get_num_members(), sd, tangent_polys.coeffs.shape[-1]))

    # Outer product of the tangent vectors with the quadratic edge polynomials.
    for i, (edge, dof) in enumerate(edge_dofs):
        tangent = ref_el.compute_edge_tangent(edge)

        new_coeffs[i, :, :] = numpy.outer(tangent, tangent_polys.coeffs[i, :])

    bubble_set = polynomial_set.PolynomialSet(ref_el,
                                              order,
                                              order,
                                              vec_poly_set.get_expansion_set(),
                                              new_coeffs,
                                              vec_poly_set.get_dmats())

    element_set = polynomial_set.polynomial_set_union_normalized(bubble_set, vec_poly_set)
    return element_set