Skip to content

Commit

Permalink
Merge pull request #316 from firedrakeproject/pbrubeck/cleanup-variants
Browse files Browse the repository at this point in the history
Cleanup variants
  • Loading branch information
rckirby authored Aug 19, 2024
2 parents 8db60e0 + 9a984d5 commit 9f42f95
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions tsfc/finatinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,15 @@ def convert_finiteelement(element, **kwargs):
return finat.FlattenedDimensions(finat_elem), deps

kind = element.variant()
is_interval = element.cell.cellname() == 'interval'
if kind is None:
kind = 'spectral' # default variant
is_interval = element.cell.cellname() == 'interval'

if element.family() == "Lagrange":
if element.family() in {"Raviart-Thomas", "Nedelec 1st kind H(curl)",
"Brezzi-Douglas-Marini", "Nedelec 2nd kind H(curl)",
"Argyris"}:
lmbda = partial(lmbda, variant=element.variant())
elif element.family() == "Lagrange":
if kind == 'spectral':
lmbda = finat.GaussLobattoLegendre
elif kind.startswith('integral'):
Expand All @@ -171,10 +175,6 @@ def convert_finiteelement(element, **kwargs):
else:
# Let FIAT handle the general case
lmbda = partial(finat.Lagrange, variant=kind)
elif element.family() in {"Raviart-Thomas", "Nedelec 1st kind H(curl)",
"Brezzi-Douglas-Marini", "Nedelec 2nd kind H(curl)",
"Argyris"}:
lmbda = partial(lmbda, variant=element.variant())
elif element.family() in ["Discontinuous Lagrange", "Discontinuous Lagrange L2"]:
if kind == 'spectral':
lmbda = finat.GaussLegendre
Expand All @@ -186,6 +186,8 @@ def convert_finiteelement(element, **kwargs):
lmbda = lambda *args: finat.DiscontinuousElement(finat.FDMLagrange(*args))
elif kind in 'fdm_broken' and is_interval:
lmbda = finat.FDMBrokenL2
elif kind in ['demkowicz', 'fdm']:
lmbda = partial(finat.Legendre, variant=kind)
elif kind in ['mgd', 'feec', 'qb', 'mse']:
degree = element.degree()
shift_axes = kwargs["shift_axes"]
Expand All @@ -195,16 +197,10 @@ def convert_finiteelement(element, **kwargs):
else:
# Let FIAT handle the general case
lmbda = partial(finat.DiscontinuousLagrange, variant=kind)
elif element.family() == ["DPC", "DPC L2"]:
if element.cell.geometric_dimension() == 2:
element = element.reconstruct(cell=ufl.cell.hypercube(2))
elif element.cell.geometric_dimension() == 3:
element = element.reconstruct(cell=ufl.cell.hypercube(3))
elif element.family() == "S":
if element.cell.geometric_dimension() == 2:
element = element.reconstruct(cell=ufl.cell.hypercube(2))
elif element.cell.geometric_dimension() == 3:
element = element.reconstruct(cell=ufl.cell.hypercube(3))
elif element.family() == ["DPC", "DPC L2", "S"]:
dim = element.cell.geometric_dimension()
if dim > 1:
element = element.reconstruct(cell=ufl.cell.hypercube(dim))

return lmbda(cell, element.degree()), set()

Expand Down

0 comments on commit 9f42f95

Please sign in to comment.