Skip to content

Support string subdomain_id in ufl.Measure, DirichletBC and Submesh#5199

Open
pbrubeck wants to merge 4 commits into
mainfrom
pbrubeck/feature/region-names
Open

Support string subdomain_id in ufl.Measure, DirichletBC and Submesh#5199
pbrubeck wants to merge 4 commits into
mainfrom
pbrubeck/feature/region-names

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Description

Disclaimer: This PR was implemented with Codex

Introduces native, human-readable region naming capabilities across Firedrake. By allowing users to seamlessly use string identifiers preserved from external mesh generators or explicitly assign custom semantic names to subdomains at runtime, it eliminates the cognitive overhead of tracking opaque numerical tags when defining boundary conditions, extracting submeshes, or specifying UFL variational forms.

from firedrake import *
import netgen.occ as ngocc

# 1. Generate geometry & name boundaries natively in Netgen
wp = ngocc.WorkPlane()
box = wp.Rectangle(1, 1).Face()
box.edges.Max(ngocc.Y).name = "inlet"
box.faces.name = "fluid_domain"
ngmesh = ngocc.OCCGeometry(box, dim=2).GenerateMesh(maxh=0.1)

# 2. Native Firedrake Mesh captures the names automatically
mesh = Mesh(ngmesh)

# 3. Explicitly map a single string name to multiple disjoint entity IDs

# 4. Clean, human-readable API usage
V = FunctionSpace(mesh, "CG", 1)

# DirichletBC automatically maps "inlet" to the correct face ID
bc = DirichletBC(V, 0.0, "inlet")  

# SubMesh automatically maps "fluid_domain" using the correct keyword argument
submesh = Submesh(mesh, subdomain_id="fluid_domain")

# Form language integration: UFL Measures accept string region names directly
f = Function(V)
L = f * dx(subdomain_id="fluid_domain")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant