From ddc14f069263bdf98ec181d1027a5ad855f54071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Wed, 22 May 2024 15:42:44 +0200 Subject: [PATCH] Add docstrings to submesh creation in Python interface (#3112) * Add docstrings to submesh creation * Apply suggestions from code review Co-authored-by: Garth N. Wells * 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 * Update docs and return type * Add comma to list --------- Co-authored-by: Garth N. Wells Co-authored-by: Jack S. Hale --- python/dolfinx/mesh.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python/dolfinx/mesh.py b/python/dolfinx/mesh.py index b240afc7196..6b41e7b8eb9 100644 --- a/python/dolfinx/mesh.py +++ b/python/dolfinx/mesh.py @@ -40,6 +40,7 @@ "locate_entities_boundary", "refine", "create_mesh", + "create_submesh", "Mesh", "MeshTags", "meshtags", @@ -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 )