Skip to content

make forms work more nicely with MeshSequence#479

Open
mscroggs wants to merge 9 commits intomainfrom
mscroggs/mixed-topology-form
Open

make forms work more nicely with MeshSequence#479
mscroggs wants to merge 9 commits intomainfrom
mscroggs/mixed-topology-form

Conversation

@mscroggs
Copy link
Copy Markdown
Member

@mscroggs mscroggs commented Apr 21, 2026

If a MeshSequence is used for meshes with multiple cell types (eg hexes and prisms), currently forms need to be written like this:

u_hex, u_prism = ufl.TrialFunctions(W)
v_hex, v_prism = ufl.TestFunctions(W)
prism_domain, hex_domain = py_mesh.ufl_domain().meshes
dx_hex = ufl.Measure("dx", domain=hex_domain)
dx_prism = ufl.Measure("dx", domain=prism_domain)
a = ufl.inner(ufl.grad(u_hex), ufl.grad(v_hex)) * dx_hex
a += ufl.inner(ufl.grad(u_prism), ufl.grad(v_prism)) * dx_prism

This PR updates UFL so that this form can be written like this:

u = ufl.TrialFunction(W)
v = ufl.TestFunction(W)
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * dx

The form returned in the new example is the same as in the more complex example above.

This only impacts a code path which previously threw an exception, so this should not affect and code that currently works.

Still to do:

  • Add a test

@mscroggs mscroggs marked this pull request as draft April 21, 2026 10:55
@mscroggs mscroggs marked this pull request as ready for review April 22, 2026 07:27
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