Skip to content

Commit fdde737

Browse files
committed
io: adapt to simplified plex interface
1 parent a256f33 commit fdde737

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

firedrake/checkpointing.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter
11141114
coordinates = self._load_function_topology(tmesh, coord_element, coord_name)
11151115
mesh = make_mesh_from_coordinates(coordinates, name)
11161116
# Load plex coordinates for a complete representation of plex.
1117-
tmesh.topology_dm.coordinatesLoad(self.viewer, tmesh.sfXC)
1117+
tmesh.topology_dm.coordinatesLoad(self.viewer)
11181118
# Load cell_orientations for immersed meshes.
11191119
path = self._path_to_mesh_immersed(tmesh.name, name)
11201120
if path in self.h5pyfile:
@@ -1192,9 +1192,9 @@ def _load_mesh_topology(self, tmesh_name, reorder, distribution_parameters):
11921192
format = ViewerHDF5.Format.HDF5_PETSC
11931193
self.viewer.pushFormat(format=format)
11941194
plex.distributionSetName(distribution_name)
1195-
sfXB = plex.topologyLoad(self.viewer)
1195+
plex.topologyLoad(self.viewer)
11961196
plex.distributionSetName(None)
1197-
plex.labelsLoad(self.viewer, sfXB)
1197+
plex.labelsLoad(self.viewer)
11981198
self.viewer.popFormat()
11991199
# These labels are distribution dependent.
12001200
# We should be able to save/load labels selectively.
@@ -1223,7 +1223,7 @@ def _load_mesh_topology(self, tmesh_name, reorder, distribution_parameters):
12231223
# -- Construct Mesh (Topology) --
12241224
# Use public API so pass user comm (self.comm)
12251225
tmesh = MeshTopology(plex, name=plex.getName(), reorder=reorder,
1226-
distribution_parameters=distribution_parameters, sfXB=sfXB, perm_is=perm_is,
1226+
distribution_parameters=distribution_parameters, perm_is=perm_is,
12271227
distribution_name=distribution_name, permutation_name=permutation_name,
12281228
comm=self.comm)
12291229
return tmesh
@@ -1283,9 +1283,8 @@ def _load_function_space_topology(self, tmesh, element):
12831283
section.setPermutation(tmesh._dm_renumbering)
12841284
dm.setSection(section)
12851285
base_tmesh = tmesh._base_mesh if isinstance(tmesh, ExtrudedMeshTopology) else tmesh
1286-
sfXC = base_tmesh.sfXC
12871286
topology_dm.setName(tmesh.name)
1288-
gsf, lsf = topology_dm.sectionLoad(self.viewer, dm, sfXC)
1287+
gsf, lsf = topology_dm.sectionLoad(self.viewer, dm)
12891288
topology_dm.setName(base_tmesh.name)
12901289
nodes_per_entity, real_tensorproduct, block_size = sd_key
12911290
# Don't cache if the section has been expanded by block_size

firedrake/mesh.py

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class AbstractMeshTopology(object, metaclass=abc.ABCMeta):
490490
"""A representation of an abstract mesh topology without a concrete
491491
PETSc DM implementation"""
492492

493-
def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name, permutation_name, comm, submesh_parent=None):
493+
def __init__(self, topology_dm, name, reorder, perm_is, distribution_name, permutation_name, comm, submesh_parent=None):
494494
"""Initialise a mesh topology.
495495
496496
Parameters
@@ -501,11 +501,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
501501
Name of the mesh topology.
502502
reorder : bool
503503
Whether to reorder the mesh entities.
504-
sfXB : PETSc.PetscSF
505-
`PETSc.SF` that pushes forward the global point number
506-
slab ``[0, NX)`` to input (naive) plex (only significant when
507-
the mesh topology is loaded from file and only passed from inside
508-
`~.CheckpointFile`).
509504
perm_is : PETSc.IS
510505
`PETSc.IS` that is used as ``_dm_renumbering``; only
511506
makes sense if we know the exact parallel distribution of ``plex``
@@ -526,10 +521,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
526521
topology_dm.setFromOptions()
527522
self.topology_dm = topology_dm
528523
r"The PETSc DM representation of the mesh topology."
529-
self.sfBC = None
530-
r"The PETSc SF that pushes the input (naive) plex to current (good) plex."
531-
self.sfXB = sfXB
532-
r"The PETSc SF that pushes the global point number slab [0, NX) to input (naive) plex."
533524
self.submesh_parent = submesh_parent
534525
# User comm
535526
self.user_comm = comm
@@ -540,8 +531,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
540531
self._grown_halos = False
541532
if self.comm.size > 1:
542533
self._add_overlap()
543-
if self.sfXB is not None:
544-
self.sfXC = sfXB.compose(self.sfBC) if self.sfBC else self.sfXB
545534
dmcommon.label_facets(self.topology_dm)
546535
dmcommon.complete_facet_labels(self.topology_dm)
547536
# TODO: Allow users to set distribution name if they want to save
@@ -1067,7 +1056,6 @@ def __init__(
10671056
name,
10681057
reorder,
10691058
distribution_parameters,
1070-
sfXB=None,
10711059
perm_is=None,
10721060
distribution_name=None,
10731061
permutation_name=None,
@@ -1086,11 +1074,6 @@ def __init__(
10861074
Whether to reorder the mesh entities.
10871075
distribution_parameters : dict
10881076
Options controlling mesh distribution; see `Mesh` for details.
1089-
sfXB : PETSc.PetscSF
1090-
`PETSc.SF` that pushes forward the global point number
1091-
slab ``[0, NX)`` to input (naive) plex (only significant when
1092-
the mesh topology is loaded from file and only passed from inside
1093-
`~.CheckpointFile`).
10941077
perm_is : PETSc.IS
10951078
`PETSc.IS` that is used as ``_dm_renumbering``; only
10961079
makes sense if we know the exact parallel distribution of ``plex``
@@ -1121,7 +1104,7 @@ def __init__(
11211104
# Disable auto distribution and reordering before setFromOptions is called.
11221105
plex.distributeSetDefault(False)
11231106
plex.reorderSetDefault(PETSc.DMPlex.ReorderDefaultFlag.FALSE)
1124-
super().__init__(plex, name, reorder, sfXB, perm_is, distribution_name, permutation_name, comm, submesh_parent=submesh_parent)
1107+
super().__init__(plex, name, reorder, perm_is, distribution_name, permutation_name, comm, submesh_parent=submesh_parent)
11251108

11261109
def _distribute(self):
11271110
# Distribute/redistribute the dm to all ranks
@@ -1132,9 +1115,8 @@ def _distribute(self):
11321115
# refine this mesh in parallel. Later, when we actually use
11331116
# it, we grow the halo.
11341117
original_name = plex.getName()
1135-
sfBC = plex.distribute(overlap=0)
1118+
_ = plex.distribute(overlap=0)
11361119
plex.setName(original_name)
1137-
self.sfBC = sfBC
11381120
# plex carries a new dm after distribute, which
11391121
# does not inherit partitioner from the old dm.
11401122
# It probably makes sense as chaco does not work
@@ -1150,17 +1132,15 @@ def _add_overlap(self):
11501132
elif overlap_type in [DistributedMeshOverlapType.FACET, DistributedMeshOverlapType.RIDGE]:
11511133
dmcommon.set_adjacency_callback(self.topology_dm, overlap_type)
11521134
original_name = self.topology_dm.getName()
1153-
sfBC = self.topology_dm.distributeOverlap(overlap)
1135+
_ = self.topology_dm.distributeOverlap(overlap)
11541136
self.topology_dm.setName(original_name)
1155-
self.sfBC = self.sfBC.compose(sfBC) if self.sfBC else sfBC
11561137
dmcommon.clear_adjacency_callback(self.topology_dm)
11571138
self._grown_halos = True
11581139
elif overlap_type == DistributedMeshOverlapType.VERTEX:
11591140
# Default is FEM (vertex star) adjacency.
11601141
original_name = self.topology_dm.getName()
1161-
sfBC = self.topology_dm.distributeOverlap(overlap)
1142+
_ = self.topology_dm.distributeOverlap(overlap)
11621143
self.topology_dm.setName(original_name)
1163-
self.sfBC = self.sfBC.compose(sfBC) if self.sfBC else sfBC
11641144
self._grown_halos = True
11651145
else:
11661146
raise ValueError("Unknown overlap type %r" % overlap_type)
@@ -2025,7 +2005,7 @@ def __init__(self, swarm, parentmesh, name, reorder, input_ordering_swarm=None,
20252005
"overlap_type": (DistributedMeshOverlapType.NONE, 0)}
20262006
self.input_ordering_swarm = input_ordering_swarm
20272007
self._parent_mesh = parentmesh
2028-
super().__init__(swarm, name, reorder, None, perm_is, distribution_name, permutation_name, parentmesh.comm)
2008+
super().__init__(swarm, name, reorder, perm_is, distribution_name, permutation_name, parentmesh.comm)
20292009

20302010
def _distribute(self):
20312011
pass

0 commit comments

Comments
 (0)