示例#1
0
文件: test_fiat.py 项目: tj-sun/fiat
def test_nodal_enriched_implementation():
    """Following element pair should be the same.
    This might be fragile to dof reordering but works now.
    """

    e0 = RaviartThomas(T, 2)

    e1 = NodalEnrichedElement(
        RestrictedElement(RaviartThomas(T, 2), restriction_domain='facet'),
        RestrictedElement(RaviartThomas(T, 2), restriction_domain='interior'))

    for attr in [
            "degree",
            "get_reference_element",
            "entity_dofs",
            "entity_closure_dofs",
            "get_formdegree",
            "mapping",
            "num_sub_elements",
            "space_dimension",
            "value_shape",
            "is_nodal",
    ]:
        assert getattr(e0, attr)() == getattr(e1, attr)()
    assert np.allclose(e0.get_coeffs(), e1.get_coeffs())
    assert np.allclose(e0.dmats(), e1.dmats())
    assert np.allclose(e0.get_dual_set().to_riesz(e0.get_nodal_basis()),
                       e1.get_dual_set().to_riesz(e1.get_nodal_basis()))
示例#2
0
文件: test_fiat.py 项目: tj-sun/fiat
def test_mixed_is_not_nodal():
    element = MixedElement([
        EnrichedElement(
            RaviartThomas(T, 1),
            RestrictedElement(RaviartThomas(T, 2),
                              restriction_domain="interior")),
        DiscontinuousLagrange(T, 1)
    ])

    assert not element.is_nodal()
示例#3
0
def _create_restricted_element(ufl_element):
    """Create an FFC representation for an UFL RestrictedElement."""

    if not isinstance(ufl_element, ufl.RestrictedElement):
        raise RuntimeError("create_restricted_element expects an ufl.RestrictedElement")

    base_element = ufl_element.sub_element()
    restriction_domain = ufl_element.restriction_domain()

    # If simple element -> create RestrictedElement from fiat_element
    if isinstance(base_element, ufl.FiniteElement):
        element = _create_fiat_element(base_element)
        return RestrictedElement(element, restriction_domain=restriction_domain)

    # If restricted mixed element -> convert to mixed restricted element
    if isinstance(base_element, ufl.MixedElement):
        elements = _extract_elements(base_element, restriction_domain)
        return MixedElement(elements)

    raise RuntimeError("Cannot create restricted element from: {}".format(ufl_element))