@@ -4863,6 +4863,8 @@ def Submesh(mesh, subdim=None, subdomain_id=None, label_name=None, name=None, ig
48634863 raise NotImplementedError ("Can not create a submesh of a ``VertexOnlyMesh``" )
48644864 if subdim is None :
48654865 subdim = mesh .topological_dimension
4866+ if subdomain_id == "on_boundary" :
4867+ subdim = subdim - 1
48664868 plex = mesh .topology_dm
48674869 dim = plex .getDimension ()
48684870 if subdim not in {dim , dim - 1 }:
@@ -4880,20 +4882,24 @@ def Submesh(mesh, subdim=None, subdomain_id=None, label_name=None, name=None, ig
48804882 label_name = dmcommon .FACE_SETS_LABEL
48814883
48824884 # Parse non-integer subdomain_id
4883- if subdomain_id == "on_boundary" :
4884- subdomain_id = tuple (mesh .exterior_facets .unique_markers )
4885+ if isinstance (subdomain_id , str ):
4886+ if subdomain_id == "on_boundary" :
4887+ subdomain_id = tuple (mesh .exterior_facets .unique_markers )
4888+ else :
4889+ raise ValueError (f"Submesh construction got invalid subdomain_id { subdomain_id } ." )
48854890
48864891 if isinstance (subdomain_id , Sequence ):
48874892 # Create a temporary DMLabel with the union of the labels in the list
48884893 icomm = comm or mesh .comm
48894894 iset = PETSc .IS ().createGeneral ([], comm = icomm )
48904895 for sub in subdomain_id :
4896+ try :
4897+ sub , = sub
4898+ except ValueError :
4899+ pass
48914900 if isinstance (sub , Sequence ):
48924901 # Take the intersection of the (closure of the) labels from nested lists
4893- ises = [plex .getStratumIS (label_name , subi ) for subi in sub ]
4894- closure = [[plex .getTransitiveClosure (p )[0 ] for p in i .indices ] for i in ises ]
4895- indices = reduce (np .intersect1d , closure )
4896- cur = PETSc .IS ().createGeneral (indices , comm = icomm )
4902+ cur = dmcommon .create_label_intersection (plex , label_name , sub )
48974903 else :
48984904 cur = plex .getStratumIS (label_name , sub )
48994905 iset = iset .union (cur )
0 commit comments