Skip to content

Automatic detection of Lagrange elements #4750

@pbrubeck

Description

@pbrubeck

Describe the current issue
In some parts of the code (e.g. interpolation-based (native) multigrid transfers) we need to detect whether an element has been defined using point evaluation degrees of freedom. Currently, we rely on hard-coded lists of the families and variants that are defined in such way, and we test UFL element attributes to verify this condition.

Describe the solution you'd like
An automated approach is to query the dual basis of a FInAT element as it is done in bddc.py

def is_lagrange(finat_element):
"""Returns whether finat_element.dual_basis consists only of point evaluation dofs."""
try:
Q, ps = finat_element.dual_basis
except NotImplementedError:
return False
# Inspect the weight matrix
# Lagrange elements have gem.Delta as the only terminal nodes
children = [Q]
while children:
nodes = []
for c in children:
if isinstance(c, gem.Delta):
pass
elif isinstance(c, gem.gem.Terminal):
return False
else:
nodes.extend(c.children)
children = nodes
return True

We should consider moving this code to FInAT for conveninence.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions