@@ -4328,7 +4328,7 @@ def get_dm_cell_types(PETSc.DM dm):
43284328
43294329
43304330def create_label_intersection (PETSc.DM dm , label_name , label_values ):
4331- """ Return the intersection of the closure of a subdomains of a DMPlex.
4331+ """ Return the intersection of the closure of subdomains of a DMPlex.
43324332
43334333 Parameters
43344334 ----------
@@ -4341,25 +4341,23 @@ def create_label_intersection(PETSc.DM dm, label_name, label_values):
43414341
43424342 Returns
43434343 -------
4344- tuple
4344+ PETSc.IS
43454345 A PETSc.IS with the points in the intersection.
43464346
43474347 """
43484348 cdef:
4349+ PETSc.IS iout, i1, i2
43494350 PETSc.DMLabel label
4350- PETSc.PetscIS is1, is2
4351- PetscInt val = label_values[0 ]
4351+
4352+ if len (label_values) == 0 :
4353+ return PETSc.IS().createGeneral([], comm = dm.comm)
43524354
43534355 label = dm.getLabel(label_name)
43544356 CHKERR(DMPlexLabelComplete(dm.dm, label.dmlabel))
4355- CHKERR(DMLabelGetStratumIS(< DMLabel> label.dmlabel, val, & is1))
4356-
4357- for i in range (1 , len (label_values)):
4357+ iout = label.getStratumIS(label_values[0 ])
4358+ for val in label_values[1 :]:
4359+ i1 = iout
4360+ i2 = label.getStratumIS(val)
43584361 iout = PETSc.IS()
4359- val = label_values[i]
4360- CHKERR(DMLabelGetStratumIS(< DMLabel> label.dmlabel, val, & is2))
4361- CHKERR(ISIntersect(is1, is2, & (< PETSc.IS?> iout).iset))
4362- CHKERR(ISDestroy(& is1))
4363- CHKERR(ISDestroy(& is2))
4364- is1 = (< PETSc.IS?> iout).iset
4362+ CHKERR(ISIntersect(i1.iset, i2.iset, & iout.iset))
43654363 return iout
0 commit comments