Example #1
0
def test_quad_rtcf():
    W0_h = FIAT.Lagrange(UFCInterval(), 1)
    W1_h = FIAT.DiscontinuousLagrange(UFCInterval(), 0)

    W0_v = FIAT.DiscontinuousLagrange(UFCInterval(), 0)
    W0 = FIAT.Hdiv(FIAT.TensorProductElement(W0_h, W0_v))

    W1_v = FIAT.Lagrange(UFCInterval(), 1)
    W1 = FIAT.Hdiv(FIAT.TensorProductElement(W1_h, W1_v))

    elem = FIAT.EnrichedElement(W0, W1)
    assert {0: [0, 1, 2], 1: [0, 1, 3]} == entity_support_dofs(elem, (1, 0))
    assert {0: [0, 2, 3], 1: [1, 2, 3]} == entity_support_dofs(elem, (0, 1))
Example #2
0
def test_prism_hdiv(space, degree, horiz_expected, vert_expected):
    W0_h = FIAT.supported_elements[space](UFCTriangle(), degree)
    W1_h = FIAT.DiscontinuousLagrange(UFCTriangle(), degree - 1)

    W0_v = FIAT.DiscontinuousLagrange(UFCInterval(), degree - 1)
    W0 = FIAT.Hdiv(FIAT.TensorProductElement(W0_h, W0_v))

    W1_v = FIAT.Lagrange(UFCInterval(), degree)
    W1 = FIAT.Hdiv(FIAT.TensorProductElement(W1_h, W1_v))

    elem = FIAT.EnrichedElement(W0, W1)
    assert horiz_expected == entity_support_dofs(elem, (2, 0))
    assert vert_expected == entity_support_dofs(elem, (1, 1))
Example #3
0
def _(element, vector_is_mixed):
    return FIAT.Hdiv(create_element(element._element, vector_is_mixed))
Example #4
0
def _create_hdiv_finiteelement(
        element: ufl.HDivElement) -> FIAT.TensorProductElement:
    tp = _create_element(element._element)
    return FIAT.Hdiv(tp)
Example #5
0
def convert_hdivelement(element, vector_is_mixed):
    return FIAT.Hdiv(create_element(element._element, vector_is_mixed))
Example #6
0
def create_actual_fiat_element(ufl_element):
    fiat_element = None

    # Check if finite element family is supported by FIAT
    family = ufl_element.family()
    if not family in FIAT.supported_elements:
        # We support RTCE and RTCF elements on quadrilaterals,
        # even though they are not supported by FIAT.
        if ufl_element.cell().cellname() == "quadrilateral":
            fiat_element = create_actual_fiat_element(
                reconstruct_element(ufl_element, ufl_element.family(),
                                    _quad_opc, ufl_element.degree()))
        else:
            if family in ("FacetElement", "InteriorElement"):
                # rescue these
                pass
            else:
                error(
                    "Sorry, finite element of type \"%s\" are not supported by FIAT.",
                    family)

    # Skip all cases if FIAT element is ready already
    if fiat_element is not None:
        pass
    # HDiv and HCurl elements have family "OuterProductElement",
    # so get matching FIAT element directly rather than via lookup
    elif isinstance(ufl_element, ufl.HDivElement):
        fiat_element = FIAT.Hdiv(create_element(ufl_element._element))
    elif isinstance(ufl_element, ufl.HCurlElement):
        fiat_element = FIAT.Hcurl(create_element(ufl_element._element))
    elif isinstance(ufl_element, ufl.FacetElement):
        fiat_element = FIAT.RestrictedElement(create_element(
            ufl_element._element),
                                              restriction_domain="facet")
    elif isinstance(ufl_element, ufl.InteriorElement):
        fiat_element = FIAT.RestrictedElement(create_element(
            ufl_element._element),
                                              restriction_domain="interior")
    else:
        # Look up FIAT element
        ElementClass = FIAT.supported_elements[family]

        if isinstance(ufl_element, ufl.EnrichedElement):
            A = create_element(ufl_element._elements[0])
            B = create_element(ufl_element._elements[1])
            fiat_element = ElementClass(A, B)
        # OPVE is only here to satisfy calls from Firedrake
        elif isinstance(
                ufl_element,
            (ufl.OuterProductElement, ufl.OuterProductVectorElement,
             ufl.OuterProductTensorElement)):
            cell = ufl_element.cell()
            if not isinstance(cell, ufl.OuterProductCell):
                error(
                    "An OuterProductElement must have an OuterProductCell as domain, sorry."
                )

            A = create_element(ufl_element._A)
            B = create_element(ufl_element._B)
            fiat_element = ElementClass(A, B)
        elif isinstance(ufl_element, (ufl.BrokenElement, ufl.TraceElement)):
            fiat_element = ElementClass(create_element(ufl_element._element))
        elif ufl_element.cell().cellname() == "quadrilateral":
            fiat_element = create_actual_fiat_element(
                ufl_element.reconstruct(domain=_quad_opc))
        else:
            # "Normal element" case
            cell = ufl_element.cell()
            degree = ufl_element.degree()
            fiat_cell = reference_cell(cell)
            fiat_element = ElementClass(fiat_cell, degree)

    if fiat_element is None:
        raise Exception(
            "Something strange happened: reached end of function without returning an element"
        )

    if ufl_element.cell().cellname() == "quadrilateral" and \
            isinstance(fiat_element.get_reference_element(),
                       FIAT.reference_element.two_product_cell):
        # Flatten tensor product element

        from FIAT.reference_element import FiredrakeQuadrilateral
        from FIAT.dual_set import DualSet

        nodes = fiat_element.dual.nodes
        ref_el = FiredrakeQuadrilateral()

        entity_ids = fiat_element.dual.entity_ids
        flat_entity_ids = {}
        flat_entity_ids[0] = entity_ids[(0, 0)]
        flat_entity_ids[1] = dict(
            enumerate(entity_ids[(0, 1)].values() +
                      entity_ids[(1, 0)].values()))
        flat_entity_ids[2] = entity_ids[(1, 1)]

        fiat_element.dual = DualSet(nodes, ref_el, flat_entity_ids)
        fiat_element.ref_el = ref_el

    return fiat_element