Skip to content

Commit b6e2847

Browse files
authored
cache visible_ranks on topology (#5183)
* cache on topology * make private
1 parent f545557 commit b6e2847

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

firedrake/mesh.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,18 @@ def trans_mesh_entity_map(self, base_mesh, base_integral_type, base_subdomain_id
17641764
composed_map, integral_type, _ = self.submesh_map_composed(base_mesh, base_integral_type, base_subset_points)
17651765
return composed_map, integral_type
17661766

1767+
@cached_property
1768+
def _visible_ranks(self):
1769+
# Get parent mesh rank ownership information.
1770+
visible_ranks = np.empty(self.cell_set.total_size, dtype=IntType)
1771+
visible_ranks[:self.cell_set.size] = self.comm.rank
1772+
visible_ranks[self.cell_set.size:] = -1
1773+
# Halo exchange the visible ranks so that each rank knows which ranks can see each cell.
1774+
dmcommon.exchange_cell_orientations(
1775+
self.topology_dm, self._cell_numbering, visible_ranks
1776+
)
1777+
return visible_ranks
1778+
17671779

17681780
class ExtrudedMeshTopology(MeshTopology):
17691781
"""Representation of an extruded mesh topology."""
@@ -4412,13 +4424,7 @@ def _parent_mesh_embedding(
44124424
reference_coords = reference_coords[:, : parent_mesh.topological_dimension]
44134425

44144426
# Get parent mesh rank ownership information.
4415-
visible_ranks = np.empty(parent_mesh.cell_set.total_size, dtype=IntType)
4416-
visible_ranks[:parent_mesh.cell_set.size] = parent_mesh.comm.rank
4417-
visible_ranks[parent_mesh.cell_set.size:] = -1
4418-
# Halo exchange the visible ranks so that each rank knows which ranks can see each cell.
4419-
dmcommon.exchange_cell_orientations(
4420-
parent_mesh.topology.topology_dm, parent_mesh.topology._cell_numbering, visible_ranks
4421-
)
4427+
visible_ranks = parent_mesh._visible_ranks
44224428
locally_visible = parent_cell_nums != -1
44234429

44244430
if parent_mesh.extruded:

0 commit comments

Comments
 (0)