From ff0f5f9eaeed38b5bf1c20aa24f2e2d2e05f438c Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 14 Mar 2023 21:10:06 -0500 Subject: [PATCH] Fix for Firedrake removing _Facets.markers https://github.com/firedrakeproject/firedrake/commit/9125a65c0cb5bb671c62c33f05a0d42b983e06ed, in which 'deprecate' appears to mean 'remove without prior warning or suggested recourse'. --- meshmode/interop/firedrake/mesh.py | 24 +++++++++++++++++++++++- test/test_firedrake_interop.py | 5 ++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/meshmode/interop/firedrake/mesh.py b/meshmode/interop/firedrake/mesh.py index 913ebcf5..75f356ff 100644 --- a/meshmode/interop/firedrake/mesh.py +++ b/meshmode/interop/firedrake/mesh.py @@ -199,6 +199,25 @@ def _get_firedrake_boundary_tags(fdrake_mesh, tag_induced_boundary=False): return bdy_tags +def _get_facet_markers(dm, facets): + # based on code removed in + # https://github.com/firedrakeproject/firedrake/commit/9125a65c0cb5bb671c62c33f05a0d42b983e06ed + import firedrake.cython.dmcommon as dmcommon + + ids = np.empty_like(facets) + ids.fill(-1) + + nfacet = facets.shape[0] + label = dm.getLabel(dmcommon.FACE_SETS_LABEL) + if not label: + return + + for f in range(nfacet): + ids[f] = label.getValue(facets[f]) + + return ids + + def _get_firedrake_facial_adjacency_groups(fdrake_mesh_topology, cells_to_use=None): """ @@ -333,7 +352,10 @@ def _get_firedrake_facial_adjacency_groups(fdrake_mesh_topology, dtype=Mesh.face_id_dtype) # If only using some of the cells, throw away unused cells and # move to new cell index - ext_facet_markers = top.exterior_facets.markers + + ext_facet_markers = _get_facet_markers( + top.topology_dm, top.exterior_facets.facets) + if cells_to_use is not None: to_keep = np.isin(ext_elements, cells_to_use) ext_elements = np.vectorize(cells_to_use_inv.__getitem__)( diff --git a/test/test_firedrake_interop.py b/test/test_firedrake_interop.py index 164c3bd7..67e0a8dc 100644 --- a/test/test_firedrake_interop.py +++ b/test/test_firedrake_interop.py @@ -334,8 +334,11 @@ def test_bdy_tags(square_or_cube_mesh, bdy_ids, coord_indices, coord_values, # Verify that the number of meshes tagged with a boundary tag # is the same in meshmode and firedrake for each tag in *bdy_ids* + from meshmode.interop.firedrake.mesh import _get_facet_markers fdrake_bdy_ids, fdrake_counts = \ - np.unique(square_or_cube_mesh.exterior_facets.markers, return_counts=True) + np.unique(_get_facet_markers( + square_or_cube_mesh.topology.topology_dm, + square_or_cube_mesh.exterior_facets.facets), return_counts=True) assert set(fdrake_bdy_ids) == set(bdy_ids) for bdy_id, fdrake_count in zip(fdrake_bdy_ids, fdrake_counts): assert fdrake_count == bdy_id_to_mm_count[bdy_id] -- GitLab