Skip to content

Commit 3c5f20d

Browse files
committed
fixes
1 parent 9d39035 commit 3c5f20d

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

firedrake/cython/dmcommon.pyx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4328,7 +4328,7 @@ def get_dm_cell_types(PETSc.DM dm):
43284328

43294329

43304330
def 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

firedrake/mesh.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4890,15 +4890,10 @@ def Submesh(mesh, subdim=None, subdomain_id=None, label_name=None, name=None, ig
48904890

48914891
if isinstance(subdomain_id, Sequence):
48924892
# Create a temporary DMLabel with the union of the labels in the list
4893-
icomm = comm or mesh.comm
4894-
iset = PETSc.IS().createGeneral([], comm=icomm)
4893+
iset = PETSc.IS().createGeneral([], comm=mesh.comm)
48954894
for sub in subdomain_id:
4896-
try:
4897-
sub, = sub
4898-
except ValueError:
4899-
pass
49004895
if isinstance(sub, Sequence):
4901-
# Take the intersection of the (closure of the) labels from nested lists
4896+
# Take the intersection of the labels from nested lists
49024897
cur = dmcommon.create_label_intersection(plex, label_name, sub)
49034898
else:
49044899
cur = plex.getStratumIS(label_name, sub)

0 commit comments

Comments
 (0)