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

Wrap C++ Mesh from Python (fixes support for Python 3.11) #2500

Merged
merged 30 commits into from Jan 28, 2023

Conversation

garth-wells
Copy link
Member

@garth-wells garth-wells commented Jan 6, 2023

The difference between C++ and Python meshes is that Python meshes have ufl_cell and ufl_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 how FunctionSpace is handled on the Python side. The upside of the extra hand-coding is that docstring are easier to write.

@garth-wells garth-wells added bug Something isn't working proposal Suggested change or addition in progress high-priority labels Jan 6, 2023
python/dolfinx/geometry.py Outdated Show resolved Hide resolved
python/dolfinx/mesh.py Outdated Show resolved Hide resolved
@garth-wells
Copy link
Member Author

PR is at draft stage. No need for detailed comments yet, plenty to fix up first.

@garth-wells garth-wells marked this pull request as ready for review January 27, 2023 16:28
@garth-wells
Copy link
Member Author

@jorgensd, @francesco-ballarin PR is ready now if you have more comments.

Copy link
Member

@francesco-ballarin francesco-ballarin left a 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!

@garth-wells garth-wells changed the title Wrap C++ Mesh from Python Wrap C++ Mesh from Python (fixes support for Python 3.11) Jan 28, 2023
Copy link
Sponsor Member

@jorgensd jorgensd left a 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)
Copy link
Sponsor Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority in progress proposal Suggested change or addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test on Python 3.11
3 participants