-
-
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
Wrap C++ Mesh
from Python (fixes support for Python 3.11)
#2500
Conversation
PR is at draft stage. No need for detailed comments yet, plenty to fix up first. |
734d29d
to
a5de737
Compare
@jorgensd, @francesco-ballarin PR is ready now if you have more comments. |
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.
Looks good to me!
Mesh
from PythonMesh
from Python (fixes support for Python 3.11)
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.
All Good. Only one note about an extra Python wrapper for dolfinx.cpp.mesh.h
@@ -330,7 +330,7 @@ def test_facet_h(ct): | |||
N = 3 | |||
mesh = create_unit_cube(MPI.COMM_WORLD, N, N, N, ct) | |||
left_facets = locate_entities_boundary(mesh, mesh.topology.dim - 1, lambda x: np.isclose(x[0], 0)) | |||
h = _cpp.mesh.h(mesh, mesh.topology.dim - 1, left_facets) | |||
h = _cpp.mesh.h(mesh._cpp_object, mesh.topology.dim - 1, left_facets) |
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.
Maybe we should make a Pythonwrapper for cpp.mesh.h?
The difference between C++ and Python meshes is that Python meshes have
ufl_cell
andufl_domain
methods. The 'trick' used to handle mesh construction does not work with Python 3.11 (see #2423 (comment)).This change wraps all
Mesh
instances in Python. This change is simple and fixes #2423, and will allow straightforward future support of different precision mesh geometry storage. It does, however, involve more hand-coding of methods and functions that operate of meshes. The design is similar to howFunctionSpace
is handled on the Python side. The upside of the extra hand-coding is that docstring are easier to write.