def test_quad_rtce(): W0_h = FIAT.Lagrange(UFCInterval(), 1) W1_h = FIAT.DiscontinuousLagrange(UFCInterval(), 0) W0_v = FIAT.DiscontinuousLagrange(UFCInterval(), 0) W0 = FIAT.Hcurl(FIAT.TensorProductElement(W0_h, W0_v)) W1_v = FIAT.Lagrange(UFCInterval(), 1) W1 = FIAT.Hcurl(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))
def test_prism_hcurl(space, degree, horiz_expected, vert_expected): W0_h = FIAT.Lagrange(UFCTriangle(), degree) W1_h = FIAT.supported_elements[space](UFCTriangle(), degree) W0_v = FIAT.DiscontinuousLagrange(UFCInterval(), degree - 1) W0 = FIAT.Hcurl(FIAT.TensorProductElement(W0_h, W0_v)) W1_v = FIAT.Lagrange(UFCInterval(), degree) W1 = FIAT.Hcurl(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))
def _(element, vector_is_mixed): return FIAT.Hcurl(create_element(element._element, vector_is_mixed))
def _create_hcurl_finiteelement( element: ufl.HCurlElement) -> FIAT.TensorProductElement: tp = _create_element(element._element) return FIAT.Hcurl(tp)
def convert_hcurlelement(element, vector_is_mixed): return FIAT.Hcurl(create_element(element._element, vector_is_mixed))
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