Ejemplo n.º 1
0
def get_line_nodes(V):
    # Return the Line nodes for Q, DQ, RTCF/E, NCF/E
    from FIAT.reference_element import UFCInterval
    from FIAT import quadrature
    use_tensorproduct, N, ndim, sub_families, variant = tensor_product_space_query(
        V)
    assert use_tensorproduct
    cell = UFCInterval()
    if variant == "equispaced" and sub_families <= {
            "Q", "DQ", "Lagrange", "Discontinuous Lagrange"
    }:
        return [cell.make_points(1, 0, N + 1)] * ndim
    elif sub_families <= {"Q", "Lagrange"}:
        rule = quadrature.GaussLobattoLegendreQuadratureLineRule(cell, N + 1)
        return [rule.get_points()] * ndim
    elif sub_families <= {"DQ", "Discontinuous Lagrange"}:
        rule = quadrature.GaussLegendreQuadratureLineRule(cell, N + 1)
        return [rule.get_points()] * ndim
    elif sub_families < {"RTCF", "NCF"}:
        cg = quadrature.GaussLobattoLegendreQuadratureLineRule(cell, N + 1)
        dg = quadrature.GaussLegendreQuadratureLineRule(cell, N)
        return [cg.get_points()] + [dg.get_points()] * (ndim - 1)
    elif sub_families < {"RTCE", "NCE"}:
        cg = quadrature.GaussLobattoLegendreQuadratureLineRule(cell, N + 1)
        dg = quadrature.GaussLegendreQuadratureLineRule(cell, N)
        return [dg.get_points()] + [cg.get_points()] * (ndim - 1)
    else:
        raise ValueError("Don't know how to get line nodes for %s" %
                         V.ufl_element())
Ejemplo n.º 2
0
    def __init__(self, ref_el, degree):
        entity_ids = {0: {0: [], 1: []},
                      1: {0: list(range(0, degree+1))}}
        lr = quadrature.GaussLegendreQuadratureLineRule(ref_el, degree+1)
        nodes = [functional.PointEvaluation(ref_el, x) for x in lr.pts]

        super().__init__(nodes, ref_el, entity_ids)
Ejemplo n.º 3
0
    def __init__(self, ref_el, degree, order=1):
        bc_nodes = []
        for x in ref_el.get_vertices():
            bc_nodes.append([functional.PointEvaluation(ref_el, x),
                             *[functional.PointDerivative(ref_el, x, [alpha]) for alpha in range(1, order)]])
        bc_nodes[1].reverse()
        k = len(bc_nodes[0])
        idof = slice(k, -k)
        bdof = list(range(-k, k))
        bdof = bdof[k:] + bdof[:k]

        # Define the generalized eigenproblem on a GLL element
        gll = GaussLobattoLegendre(ref_el, degree)
        xhat = numpy.array([list(x.get_point_dict().keys())[0][0] for x in gll.dual_basis()])

        # Tabulate the BC nodes
        constraints = gll.tabulate(order-1, ref_el.get_vertices())
        C = numpy.column_stack(list(constraints.values()))
        perm = list(range(len(bdof)))
        perm = perm[::2] + perm[-1::-2]
        C = C[:, perm].T

        # Tabulate the basis that splits the DOFs into interior and bcs
        E = numpy.eye(gll.space_dimension())
        E[bdof, idof] = -C[:, idof]
        E[bdof, :] = numpy.dot(numpy.linalg.inv(C[:, bdof]), E[bdof, :])

        # Assemble the constrained Galerkin matrices on the reference cell
        rule = quadrature.GaussLegendreQuadratureLineRule(ref_el, degree+1)
        phi = gll.tabulate(order, rule.get_points())
        E0 = numpy.dot(phi[(0, )].T, E)
        Ek = numpy.dot(phi[(order, )].T, E)
        B = numpy.dot(numpy.multiply(E0.T, rule.get_weights()), E0)
        A = numpy.dot(numpy.multiply(Ek.T, rule.get_weights()), Ek)

        # Eigenfunctions in the constrained basis
        S = numpy.eye(A.shape[0])
        if S.shape[0] > len(bdof):
            _, Sii = sym_eig(A[idof, idof], B[idof, idof])
            S[idof, idof] = Sii
            S[idof, bdof] = numpy.dot(Sii, numpy.dot(Sii.T, -B[idof, bdof]))

        # Eigenfunctions in the Lagrange basis
        S = numpy.dot(E, S)
        self.gll_points = xhat
        self.gll_tabulation = S.T

        # Interpolate eigenfunctions onto the quadrature points
        basis = numpy.dot(S.T, phi[(0, )])
        nodes = bc_nodes[0] + [functional.IntegralMoment(ref_el, rule, f) for f in basis[idof]] + bc_nodes[1]

        entity_ids = {0: {0: [0], 1: [degree]},
                      1: {0: list(range(1, degree))}}
        entity_permutations = {}
        entity_permutations[0] = {0: {0: [0]}, 1: {0: [0]}}
        entity_permutations[1] = {0: make_entity_permutations(1, degree - 1)}
        super(FDMDual, self).__init__(nodes, ref_el, entity_ids, entity_permutations)
Ejemplo n.º 4
0
    def __init__(self, ref_el, degree):
        entity_ids = {0: {0: [], 1: []}, 1: {0: list(range(0, degree + 1))}}
        lr = quadrature.GaussLegendreQuadratureLineRule(ref_el, degree + 1)
        nodes = [functional.PointEvaluation(ref_el, x) for x in lr.pts]
        entity_permutations = {}
        entity_permutations[0] = {0: {0: []}, 1: {0: []}}
        entity_permutations[1] = {0: make_entity_permutations(1, degree + 1)}

        super(GaussLegendreDualSet, self).__init__(nodes, ref_el, entity_ids,
                                                   entity_permutations)
Ejemplo n.º 5
0
def get_line_nodes(V):
    # Return the corresponding nodes in the Line for CG / DG
    from FIAT.reference_element import UFCInterval
    from FIAT import quadrature
    use_tensorproduct, N, family, variant = tensor_product_space_query(V)
    assert use_tensorproduct
    cell = UFCInterval()
    if variant == "equispaced":
        return cell.make_points(1, 0, N + 1)
    elif family <= {"Q", "Lagrange"}:
        rule = quadrature.GaussLobattoLegendreQuadratureLineRule(cell, N + 1)
        return rule.get_points()
    elif family <= {"DQ", "Discontinuous Lagrange"}:
        rule = quadrature.GaussLegendreQuadratureLineRule(cell, N + 1)
        return rule.get_points()
    else:
        raise ValueError("Don't know how to get line nodes for %r" % family)
Ejemplo n.º 6
0
    def get_nodes_1d(V):
        # Return GLL nodes if V==CG or GL nodes if V==DG
        from FIAT import quadrature
        from FIAT.reference_element import DefaultLine
        use_tensorproduct, N, family, variant = tensor_product_space_query(V)
        assert use_tensorproduct
        if family <= {"Q", "Lagrange"}:
            if variant == "equispaced":
                nodes = np.linspace(-1.0E0, 1.0E0, N+1)
            else:
                rule = quadrature.GaussLobattoLegendreQuadratureLineRule(DefaultLine(), N+1)
                nodes = np.asarray(rule.get_points()).flatten()
        elif family <= {"DQ", "Discontinuous Lagrange"}:
            if variant == "equispaced":
                nodes = np.arange(1, N+2)*(2.0E0/(N+2))-1.0E0
            else:
                rule = quadrature.GaussLegendreQuadratureLineRule(DefaultLine(), N+1)
                nodes = np.asarray(rule.get_points()).flatten()
        else:
            raise ValueError("Don't know how to get nodes for %r" % family)

        return nodes