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()
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()
def create_element(ufl_element): # Create element signature for caching (just use UFL element) element_signature = ufl_element # Check cache if element_signature in _cache: logger.debug("Reusing element from cache") return _cache[element_signature] if isinstance(ufl_element, ufl.FiniteElement): element = _create_fiat_element(ufl_element) elif isinstance(ufl_element, ufl.MixedElement): elements = _extract_elements(ufl_element) element = MixedElement(elements) elif isinstance(ufl_element, ufl.EnrichedElement): elements = [create_element(e) for e in ufl_element._elements] element = EnrichedElement(*elements) elif isinstance(ufl_element, ufl.NodalEnrichedElement): elements = [create_element(e) for e in ufl_element._elements] element = NodalEnrichedElement(*elements) elif isinstance(ufl_element, ufl.RestrictedElement): element = _create_restricted_element(ufl_element) raise RuntimeError("Cannot handle this element type: {}".format(ufl_element)) # Store in cache _cache[element_signature] = element return element
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))
def create_element(ufl_element): # Create element signature for caching (just use UFL element) element_signature = ufl_element # Check cache if element_signature in _cache: debug("Reusing element from cache") return _cache[element_signature] # Create regular FIAT finite element if isinstance(ufl_element, ufl.FiniteElement): element = _create_fiat_element(ufl_element) # Create mixed element (implemented by FFC) elif isinstance(ufl_element, ufl.MixedElement): elements = _extract_elements(ufl_element) element = MixedElement(elements) # Create element union elif isinstance(ufl_element, ufl.EnrichedElement): elements = [create_element(e) for e in ufl_element._elements] element = EnrichedElement(*elements) # Create nodal element union elif isinstance(ufl_element, ufl.NodalEnrichedElement): elements = [create_element(e) for e in ufl_element._elements] element = NodalEnrichedElement(*elements) # Create restricted element elif isinstance(ufl_element, ufl.RestrictedElement): element = _create_restricted_element(ufl_element) else: error("Cannot handle this element type: %s" % str(ufl_element)) # Store in cache _cache[element_signature] = element return element
def test_mixed_is_nodal(): element = MixedElement([DiscontinuousLagrange(T, 1), RaviartThomas(T, 2)]) assert element.is_nodal()
def test_mixed_is_nodal(): element = MixedElement([DiscontinuousLagrange(T, 1), RaviartThomas(T, 2)]) assert element.is_nodal()