Skip to content

Commit f391c06

Browse files
committed
allow for ghost only mesh
1 parent 0164941 commit f391c06

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

firedrake/cython/dmcommon.pyx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,7 @@ def get_cell_remote_ranks(PETSc.DM plex):
24712471
:arg plex: The DMPlex object encapsulating the mesh topology
24722472
"""
24732473
cdef:
2474-
PetscInt cStart, cEnd, ncells, i
2474+
PetscInt cStart, cEnd, ncells, i, p
24752475
PETSc.SF sf
24762476
PetscInt nroots, nleaves
24772477
const PetscInt *ilocal = NULL
@@ -2487,8 +2487,9 @@ def get_cell_remote_ranks(PETSc.DM plex):
24872487
CHKERR(PetscSFGetGraph(sf.sf, &nroots, &nleaves, &ilocal, &iremote))
24882488

24892489
for i in range(nleaves):
2490-
if cStart <= ilocal[i] < cEnd:
2491-
result[ilocal[i] - cStart] = iremote[i].rank
2490+
p = ilocal[i] if ilocal else i
2491+
if cStart <= p < cEnd:
2492+
result[p - cStart] = iremote[i].rank
24922493

24932494
return result
24942495

@@ -3290,7 +3291,7 @@ def exchange_cell_orientations(
32903291
# Overwrite values in the halo region with remote values
32913292
get_height_stratum(plex.dm, 0, &cStart, &cEnd)
32923293
for i in range(nleaves):
3293-
c = ilocal[i]
3294+
c = ilocal[i] if ilocal else i
32943295
if cStart <= c < cEnd:
32953296
CHKERR(PetscSectionGetOffset(section.sec, c, &l))
32963297
CHKERR(PetscSectionGetOffset(new_section.sec, c, &r))
@@ -3430,7 +3431,7 @@ def set_adjacency_callback(PETSc.DM dm not None):
34303431
CHKERR(DMGetLabel(dm.dm, "ghost_region", &label))
34313432
get_chart(dm.dm, &pStart, &pEnd)
34323433
for p in range(nleaves):
3433-
CHKERR(DMLabelSetValue(label, ilocal[p], 1))
3434+
CHKERR(DMLabelSetValue(label, ilocal[p] if ilocal else p, 1))
34343435
CHKERR(DMLabelCreateIndex(label, pStart, pEnd))
34353436
CHKERR(DMPlexSetAdjacencyUser(dm.dm, DMPlexGetAdjacency_Facet_Support, NULL))
34363437

@@ -3479,7 +3480,7 @@ def compute_point_cone_global_sizes(PETSc.DM dm):
34793480
CHKERR(DMPlexGetConeSize(dm.dm, p, &coneSize))
34803481
arraySizes[1] += coneSize;
34813482
for i in range(nleaves):
3482-
CHKERR(DMPlexGetConeSize(dm.dm, ilocal[i], &coneSize))
3483+
CHKERR(DMPlexGetConeSize(dm.dm, ilocal[i] if ilocal else i, &coneSize))
34833484
arraySizes[1] -= coneSize;
34843485
out = np.zeros((2, ), dtype=IntType)
34853486
dm.comm.tompi4py().Allreduce(arraySizes, out, op=MPI.SUM)
@@ -3603,15 +3604,15 @@ def create_halo_exchange_sf(PETSc.DM dm):
36033604
n = 0
36043605
# ilocal == NULL if local leaf points are [0, 1, 2, ...).
36053606
for i in range(nleaves):
3606-
p = ilocal[i] if ilocal != NULL else i
3607+
p = ilocal[i] if ilocal else i
36073608
CHKERR(PetscSectionGetDof(local_sec.sec, p, &dof))
36083609
n += dof
36093610
CHKERR(PetscMalloc1(n, &dof_ilocal))
36103611
CHKERR(PetscMalloc1(n, &dof_iremote))
36113612
n = 0
36123613
for i in range(nleaves):
36133614
# ilocal == NULL if local leaf points are [0, 1, 2, ...).
3614-
p = ilocal[i] if ilocal != NULL else i
3615+
p = ilocal[i] if ilocal else i
36153616
assert remote_offsets[p] >= 0
36163617
CHKERR(PetscSectionGetDof(local_sec.sec, p, &dof))
36173618
CHKERR(PetscSectionGetOffset(local_sec.sec, p, &off))
@@ -3696,7 +3697,7 @@ def submesh_correct_entity_classes(PETSc.DM dm,
36963697
ownership_loss = np.zeros(pEnd - pStart, dtype=IntType)
36973698
ownership_gain = np.zeros(pEnd - pStart, dtype=IntType)
36983699
for i in range(nleaves):
3699-
p = ilocal[i] if ilocal != NULL else i
3700+
p = ilocal[i] if ilocal else i
37003701
ownership_loss[p] = 1
37013702
unit = MPI._typedict[np.dtype(IntType).char]
37023703
ownership_transfer_sf.reduceBegin(unit, ownership_loss, ownership_gain, MPI.REPLACE)

0 commit comments

Comments
 (0)