-
-
Notifications
You must be signed in to change notification settings - Fork 182
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
Create Basix elements directly, rather than going via UFL #2301
Conversation
…to mscroggs/basix-element
@@ -17,6 +17,8 @@ | |||
import numpy as np | |||
import numpy.typing as npt | |||
|
|||
import basix | |||
import basix.ufl_wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this import required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. As UFL is an optional dependency of Basix, this is not imported as part of basix by default to avoid errors for any users without UFL installed
@@ -9,7 +9,10 @@ | |||
import numpy as np | |||
import numpy.typing as npt | |||
|
|||
import basix | |||
import basix.ufl_wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this import required?
python/dolfinx/io/gmshio.py
Outdated
return ufl.Mesh(ufl.VectorElement(scalar_element)) | ||
|
||
element = basix.ufl_wrapper.create_vector_element( | ||
"Lagrange", cell.cellname(), degree, basix.LagrangeVariant.equispaced, dim=gdim, gdim=gdim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a Basix enum
for Lagrange?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although the create_*_element
convenience functions can also accept strings which are then converted using functions like basix.finite_element.string_to_family
.
In this case, I've changed "Lagrange"
to basix.ElementFamily.P
cell.cellname()
is also a string, but I think it's best to leave it as so as the alternative is something ugly like attr(basix.CellType, cell.cellname())
Made functions in the Python interface use Basix's UFL wrapper rather than making UFL elements that FFCx will later convert to element from Basix's UFL wrapper.
This depends on FEniCS/ufl#117, FEniCS/basix#575, and FEniCS/ffcx#515.These have been merged now.