Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup variants #316

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading