Skip to content

Commit 48519e4

Browse files
committed
DirichletBC: support string subdomain_id
1 parent 43a5050 commit 48519e4

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

firedrake/cython/dmcommon.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,6 +3838,10 @@ def submesh_create(PETSc.DM dm,
38383838
subdm.removeLabel(temp_label_name)
38393839
submesh_update_facet_labels(dm, subdm)
38403840
submesh_correct_entity_classes(dm, subdm, ownership_transfer_sf)
3841+
3842+
# Propagate python attributes
3843+
for key, value in dm.getDict().items():
3844+
subdm.setAttr(key, value)
38413845
return subdm
38423846

38433847

firedrake/dmhooks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,3 +499,13 @@ def attach_hooks(dm, level=None, sf=None, section=None):
499499
# a non-mixed space)
500500
dm.setCreateFieldDecomposition(create_field_decomposition)
501501
dm.setCreateSubDM(create_subdm)
502+
503+
504+
def migrate_dm_attrs(parent_dm, child_dm):
505+
"""Migrate python attributes from one DM to another.
506+
507+
:arg parent_dm: the parent DM
508+
:arg child_dm: the child DM
509+
"""
510+
for key, value in parent_dm.getDict().items():
511+
child_dm.setAttr(key, value)

firedrake/functionspacedata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ def __str__(self):
478478

479479
@PETSc.Log.EventDecorator()
480480
def boundary_nodes(self, V, sub_domain):
481+
region_names = V.mesh().topology_dm.getAttr("face_region_names") or {}
482+
sub_domain = region_names.get(sub_domain, sub_domain)
481483
if sub_domain in ["bottom", "top"]:
482484
if not V.extruded:
483485
raise ValueError("Invalid subdomain '%s' for non-extruded mesh",

firedrake/mg/mesh.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from firedrake import utils
1313
from firedrake.cython import mgimpl as impl
14+
from firedrake.dmhooks import migrate_dm_attrs
1415
from .utils import set_level
1516

1617
__all__ = ("HierarchyBase", "MeshHierarchy", "ExtrudedMeshHierarchy", "NonNestedHierarchy",
@@ -142,6 +143,7 @@ def MeshHierarchy(mesh, refinement_levels,
142143
if i % refinements_per_level == 0:
143144
before(cdm, i)
144145
rdm = cdm.refine()
146+
migrate_dm_attrs(cdm, rdm)
145147
if i % refinements_per_level == 0:
146148
after(rdm, i)
147149
dms.append(rdm)

firedrake/mg/netgen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def uniformRefinementRoutine(ngmesh, cdm):
155155
logger.info(f"\t\t\t[{time.time()}]Refining the plex")
156156
cdm.setRefinementUniform(True)
157157
rdm = cdm.refine()
158+
dmhooks.migrate_dm_attrs(cdm, rdm)
158159
rdm.removeLabel("pyop2_core")
159160
rdm.removeLabel("pyop2_owned")
160161
rdm.removeLabel("pyop2_ghost")

0 commit comments

Comments
 (0)