Skip to content

Commit

Permalink
Add docstrings to submesh creation in Python interface (#3112)
Browse files Browse the repository at this point in the history
* Add docstrings to submesh creation

* Apply suggestions from code review

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>

* Update documentation and properly wrap submesh maps in nanobind

* Apply suggestions from code review

* Fix typo

* Reflow comment.

* Apply suggestions from code review

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>

* Update docs and return type

* Add comma to list

---------

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>
Co-authored-by: Jack S. Hale <mail@jackhale.co.uk>
  • Loading branch information
3 people committed May 22, 2024
1 parent 9f3a1b5 commit ddc14f0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion python/dolfinx/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"locate_entities_boundary",
"refine",
"create_mesh",
"create_submesh",
"Mesh",
"MeshTags",
"meshtags",
Expand Down Expand Up @@ -439,7 +440,19 @@ def create_mesh(
return Mesh(mesh, domain)


def create_submesh(msh, dim, entities):
def create_submesh(
msh: Mesh, dim: int, entities: npt.NDArray[np.int32]
) -> tuple[Mesh, npt.NDArray[np.int32], npt.NDArray[np.int32], npt.NDArray[np.int32]]:
"""Create a mesh with specified entities from another mesh.
Args:
mesh: Mesh to create the sub-mesh from.
dim: Topological dimension of the entities in ``msh`` to include in the sub-mesh.
entities: Indices of entities in ``msh`` to include in the sub-mesh.
Returns:
The (1) sub mesh, (2) entity map, (3) vertex map, and (4) node map (geometry).
Each of the maps a local index of the sub mesh to a local index of ``msh``.
"""
submsh, entity_map, vertex_map, geom_map = _cpp.mesh.create_submesh(
msh._cpp_object, dim, entities
)
Expand Down

0 comments on commit ddc14f0

Please sign in to comment.