Skip to content

Commit 9aa52ff

Browse files
committed
io: adapt to simplified plex interface
1 parent 9ae9318 commit 9aa52ff

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
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: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class AbstractMeshTopology(object, metaclass=abc.ABCMeta):
486486
"""A representation of an abstract mesh topology without a concrete
487487
PETSc DM implementation"""
488488

489-
def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name, permutation_name, comm, submesh_parent=None):
489+
def __init__(self, topology_dm, name, reorder, perm_is, distribution_name, permutation_name, comm, submesh_parent=None):
490490
"""Initialise a mesh topology.
491491
492492
Parameters
@@ -497,11 +497,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
497497
Name of the mesh topology.
498498
reorder : bool
499499
Whether to reorder the mesh entities.
500-
sfXB : PETSc.PetscSF
501-
`PETSc.SF` that pushes forward the global point number
502-
slab ``[0, NX)`` to input (naive) plex (only significant when
503-
the mesh topology is loaded from file and only passed from inside
504-
`~.CheckpointFile`).
505500
perm_is : PETSc.IS
506501
`PETSc.IS` that is used as ``_dm_renumbering``; only
507502
makes sense if we know the exact parallel distribution of ``plex``
@@ -522,10 +517,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
522517
topology_dm.setFromOptions()
523518
self.topology_dm = topology_dm
524519
r"The PETSc DM representation of the mesh topology."
525-
self.sfBC = None
526-
r"The PETSc SF that pushes the input (naive) plex to current (good) plex."
527-
self.sfXB = sfXB
528-
r"The PETSc SF that pushes the global point number slab [0, NX) to input (naive) plex."
529520
self.submesh_parent = submesh_parent
530521
# User comm
531522
self.user_comm = comm
@@ -536,8 +527,6 @@ def __init__(self, topology_dm, name, reorder, sfXB, perm_is, distribution_name,
536527
self._grown_halos = False
537528
if self.comm.size > 1:
538529
self._add_overlap()
539-
if self.sfXB is not None:
540-
self.sfXC = sfXB.compose(self.sfBC) if self.sfBC else self.sfXB
541530
dmcommon.label_facets(self.topology_dm)
542531
dmcommon.complete_facet_labels(self.topology_dm)
543532
# TODO: Allow users to set distribution name if they want to save
@@ -1057,7 +1046,6 @@ def __init__(
10571046
name,
10581047
reorder,
10591048
distribution_parameters,
1060-
sfXB=None,
10611049
perm_is=None,
10621050
distribution_name=None,
10631051
permutation_name=None,
@@ -1076,11 +1064,6 @@ def __init__(
10761064
Whether to reorder the mesh entities.
10771065
distribution_parameters : dict
10781066
Options controlling mesh distribution; see `Mesh` for details.
1079-
sfXB : PETSc.PetscSF
1080-
`PETSc.SF` that pushes forward the global point number
1081-
slab ``[0, NX)`` to input (naive) plex (only significant when
1082-
the mesh topology is loaded from file and only passed from inside
1083-
`~.CheckpointFile`).
10841067
perm_is : PETSc.IS
10851068
`PETSc.IS` that is used as ``_dm_renumbering``; only
10861069
makes sense if we know the exact parallel distribution of ``plex``
@@ -1111,7 +1094,7 @@ def __init__(
11111094
# Disable auto distribution and reordering before setFromOptions is called.
11121095
plex.distributeSetDefault(False)
11131096
plex.reorderSetDefault(PETSc.DMPlex.ReorderDefaultFlag.FALSE)
1114-
super().__init__(plex, name, reorder, sfXB, perm_is, distribution_name, permutation_name, comm, submesh_parent=submesh_parent)
1097+
super().__init__(plex, name, reorder, perm_is, distribution_name, permutation_name, comm, submesh_parent=submesh_parent)
11151098

11161099
def _distribute(self):
11171100
# Distribute/redistribute the dm to all ranks
@@ -1122,9 +1105,8 @@ def _distribute(self):
11221105
# refine this mesh in parallel. Later, when we actually use
11231106
# it, we grow the halo.
11241107
original_name = plex.getName()
1125-
sfBC = plex.distribute(overlap=0)
1108+
_ = plex.distribute(overlap=0)
11261109
plex.setName(original_name)
1127-
self.sfBC = sfBC
11281110
# plex carries a new dm after distribute, which
11291111
# does not inherit partitioner from the old dm.
11301112
# It probably makes sense as chaco does not work
@@ -1140,17 +1122,15 @@ def _add_overlap(self):
11401122
elif overlap_type in [DistributedMeshOverlapType.FACET, DistributedMeshOverlapType.RIDGE]:
11411123
dmcommon.set_adjacency_callback(self.topology_dm, overlap_type)
11421124
original_name = self.topology_dm.getName()
1143-
sfBC = self.topology_dm.distributeOverlap(overlap)
1125+
_ = self.topology_dm.distributeOverlap(overlap)
11441126
self.topology_dm.setName(original_name)
1145-
self.sfBC = self.sfBC.compose(sfBC) if self.sfBC else sfBC
11461127
dmcommon.clear_adjacency_callback(self.topology_dm)
11471128
self._grown_halos = True
11481129
elif overlap_type == DistributedMeshOverlapType.VERTEX:
11491130
# Default is FEM (vertex star) adjacency.
11501131
original_name = self.topology_dm.getName()
1151-
sfBC = self.topology_dm.distributeOverlap(overlap)
1132+
_ = self.topology_dm.distributeOverlap(overlap)
11521133
self.topology_dm.setName(original_name)
1153-
self.sfBC = self.sfBC.compose(sfBC) if self.sfBC else sfBC
11541134
self._grown_halos = True
11551135
else:
11561136
raise ValueError("Unknown overlap type %r" % overlap_type)

0 commit comments

Comments
 (0)