diff --git a/firedrake/cython/dmcommon.pyx b/firedrake/cython/dmcommon.pyx index ec7ab631af..8c2ccae6bb 100644 --- a/firedrake/cython/dmcommon.pyx +++ b/firedrake/cython/dmcommon.pyx @@ -3838,6 +3838,10 @@ def submesh_create(PETSc.DM dm, subdm.removeLabel(temp_label_name) submesh_update_facet_labels(dm, subdm) submesh_correct_entity_classes(dm, subdm, ownership_transfer_sf) + + # Propagate python attributes + for key, value in dm.getDict().items(): + subdm.setAttr(key, value) return subdm diff --git a/firedrake/dmhooks.py b/firedrake/dmhooks.py index 5b1562e84c..4d40e0f7cc 100644 --- a/firedrake/dmhooks.py +++ b/firedrake/dmhooks.py @@ -499,3 +499,13 @@ def attach_hooks(dm, level=None, sf=None, section=None): # a non-mixed space) dm.setCreateFieldDecomposition(create_field_decomposition) dm.setCreateSubDM(create_subdm) + + +def migrate_dm_attrs(parent_dm, child_dm): + """Migrate python attributes from one DM to another. + + :arg parent_dm: the parent DM + :arg child_dm: the child DM + """ + for key, value in parent_dm.getDict().items(): + child_dm.setAttr(key, value) diff --git a/firedrake/functionspacedata.py b/firedrake/functionspacedata.py index a1b6190cfb..b890145a7c 100644 --- a/firedrake/functionspacedata.py +++ b/firedrake/functionspacedata.py @@ -478,6 +478,8 @@ def __str__(self): @PETSc.Log.EventDecorator() def boundary_nodes(self, V, sub_domain): + region_names = V.mesh().topology_dm.getAttr("face_region_names") or {} + sub_domain = region_names.get(sub_domain, sub_domain) if sub_domain in ["bottom", "top"]: if not V.extruded: raise ValueError("Invalid subdomain '%s' for non-extruded mesh", diff --git a/firedrake/mg/mesh.py b/firedrake/mg/mesh.py index abd41b1716..54c14f851f 100644 --- a/firedrake/mg/mesh.py +++ b/firedrake/mg/mesh.py @@ -11,6 +11,7 @@ from firedrake import utils from firedrake.cython import mgimpl as impl +from firedrake.dmhooks import migrate_dm_attrs from .utils import set_level __all__ = ("HierarchyBase", "MeshHierarchy", "ExtrudedMeshHierarchy", "NonNestedHierarchy", @@ -142,6 +143,7 @@ def MeshHierarchy(mesh, refinement_levels, if i % refinements_per_level == 0: before(cdm, i) rdm = cdm.refine() + migrate_dm_attrs(cdm, rdm) if i % refinements_per_level == 0: after(rdm, i) dms.append(rdm) diff --git a/firedrake/mg/netgen.py b/firedrake/mg/netgen.py index aaa44ace85..7976f83f96 100644 --- a/firedrake/mg/netgen.py +++ b/firedrake/mg/netgen.py @@ -155,6 +155,7 @@ def uniformRefinementRoutine(ngmesh, cdm): logger.info(f"\t\t\t[{time.time()}]Refining the plex") cdm.setRefinementUniform(True) rdm = cdm.refine() + dmhooks.migrate_dm_attrs(cdm, rdm) rdm.removeLabel("pyop2_core") rdm.removeLabel("pyop2_owned") rdm.removeLabel("pyop2_ghost")