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

Create Basix elements directly, rather than going via UFL #2301

Merged
merged 19 commits into from
Sep 26, 2022

Conversation

mscroggs
Copy link
Member

@mscroggs mscroggs commented Jul 28, 2022

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.

@mscroggs mscroggs marked this pull request as draft July 28, 2022 15:35
@mscroggs mscroggs marked this pull request as ready for review July 28, 2022 17:07
@garth-wells garth-wells added the enhancement New feature or request label Jul 29, 2022
@@ -17,6 +17,8 @@
import numpy as np
import numpy.typing as npt

import basix
import basix.ufl_wrapper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this import required?

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this import required?

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)
Copy link
Member

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?

Copy link
Member Author

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants