-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Allow UFL element to be created from UFL cell #649
Conversation
@@ -1229,6 +1230,8 @@ def create_element(family: _typing.Union[_basix.ElementFamily, str], cell: _typi | |||
gdim: The geometric dimension of the cell. | |||
|
|||
""" | |||
if isinstance(cell, _ufl.cell.Cell): |
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.
Could try/except be used here? Nice to avoid C++ style type checks if we can.
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.
I can't see a way to do it that isn't a complete mess.
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.
The "complete mess" that would make it work:
try:
cell = cell.cellname()
except:
pass
try:
cell = _basix.cell.string_to_type(cell)
except:
pass
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.
What if we only accept a basix.CellType
? A lot of merit to there being only one way to do something.
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.
create_element
is a convenience function in the UFL wrapper to make it more user friendly to create elements. I've aimed to make the interface of this function as similar to the current UFL FiniteElement
constructor as possible and it saves most users from having to write garbage like:
element = basix.ufl_wrapper.BasixElement(basix.create_element(basix.ElementFamily.P, basix.CellType.triangle, 2, basix.LagrangeVariant.equispaced))
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.
But potentially accepting strings is enough and we don't need this additional option for input
Closing this as FEniCS/dolfinx#2604 is a better solution to this |
Fixes #648