Skip to content

BrokenMesh - #5476

Open
pbrubeck wants to merge 25 commits into
mainfrom
pbrubeck/broken-mesh
Open

pbrubeck wants to merge 25 commits into
mainfrom
pbrubeck/broken-mesh

Conversation

@pbrubeck

@pbrubeck pbrubeck commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add BrokenMesh to model faults and cracks on labelled mesh facets. A continuous Galerkin function on the broken mesh can have a different value on each side of the cut. The parent mesh supplies the facet orientation for jump integrals, and a Submesh can carry a field such as a Lagrange multiplier on the surface.

gamma = Submesh(omega, omega.topological_dimension - 1, 1)
cut = BrokenMesh(omega, 1)
V = FunctionSpace(cut, "CG", 1)
G = FunctionSpace(gamma, "CG", 1)
u = Function(V)
q = Function(G).assign(1)
dS_gamma = dS(
    1, domain=omega,
    intersect_measures=(dx(gamma), dS(domain=cut)),
)
assemble(q * jump(u)**2 * dS_gamma)

Implementation

PETSc's cohesive transform duplicates the marked facets and keeps a point map to the parent. Firedrake orders the two copies by the cells on either side of the parent facet. The broken mesh inherits the parent halo.

Evidence

The regression tests check the number of new degrees of freedom at cuts and junctions, and compare assembled jumps with exact jumps on one to three ranks. The fault-elasticity demo computes deformation from magma pressure and prescribed fault slip.

Limitations

  • Parallel cuts require ridge or vertex overlap so that both cells at a marked facet are available.
  • PETSc main includes the cohesive-label reconciliation. A separate failure affects one partial tetrahedral surface on three ranks. PETSc merge request !9845 · PETSc issue #2012

Merge risk

The change is reversible. The shared code paths are submesh assembly and point maps for mesh hierarchies.

AI tool used was OpenAI Codex.

@pbrubeck pbrubeck added the LLM used An LLM was used in the production of this PR label Sep 21, 2026
Comment thread firedrake/cython/dmcommon.pyx Resolved
Comment thread firedrake/cython/dmcommon.pyx Resolved
Comment thread firedrake/mesh.py Resolved
Comment thread firedrake/cython/dmcommon.pyx Outdated

@cython.boundscheck(False)
@cython.wraparound(False)
def create_cohesive_label(PETSc.DM dm, str label_name, PetscInt subdomain_id):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have complete_facet_labels that does a similar thing

Comment thread firedrake/cython/dmcommon.pyx Outdated
Comment on lines +4039 to +4040
CHKERR(DMPlexOrientLabel(dm.dm, cohesive))
CHKERR(DMPlexLabelCohesiveComplete(dm.dm, cohesive, NULL, 1, PETSC_FALSE, NULL))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these do?

pbrubeck and others added 3 commits September 23, 2026 17:03
- Orient the surface on the mesh without its overlap, where
  DMPlexOrientLabel supports it, and copy the flips back to the parent.
  With a RIDGE overlap, several ranks hold a copy of the same surface
  facet, and DMPlexOrientLabel reports the surface as non-orientable.
- Make the cohesive label validation collective, so that a rank without
  surface facets does not raise alone.
- Declare the local facet number and orientation kernel arguments with
  2 // arity entries per map entry, so that a broken facet map of arity
  2 gathers one entry from each side.
- Let broken cells inherit the closure ordering of their parent cells:
  submesh_create_cell_closure now takes the point map.
- Add 3D tests for the dimension of the duplicated trace space, the crack
  tip, and the jump of CG and RT functions across the surface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Place each child facet of a broken parent facet in the slot of the
  parent cell on its side. The transform numbers the two child facets in
  its own order, so the "+" side of the broken mesh could be the "-" side
  of the parent, and a signed jump across the surface changed sign on some
  ranks.
- Add hexahedral cases to the trace dimension, crack tip and jump tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Orient and complete the cohesive label on an unoverlapped copy, then transfer only the completed side labels back to the parent mesh. Add a regression test that verifies the parent cones remain unchanged.
Comment thread firedrake/mesh.py Resolved
@pbrubeck
pbrubeck force-pushed the pbrubeck/broken-mesh branch 2 times, most recently from 05b1ed7 to caec758 Compare September 27, 2026 11:59
@pbrubeck
pbrubeck force-pushed the pbrubeck/broken-mesh branch from fc5778d to 7e7a9dc Compare September 27, 2026 12:46
@pbrubeck
pbrubeck force-pushed the pbrubeck/broken-mesh branch from 41c852b to a621d35 Compare September 27, 2026 23:04
pbrubeck and others added 3 commits September 28, 2026 00:53
Add the junctions keyword to BrokenMesh. With junctions="split" or
"unsplit", each value of subdomain_id marks a separate surface, and the
surfaces are broken by one cohesive transform after another. A surface
is not split where it ends, which includes where it ends on another
surface. With "split", a surface that passes through a junction splits
it, as for faults. With "unsplit", the junction ridges are passed to
DMPlexLabelCohesiveComplete as unsplit points, so no surface splits
them, as for rivers. The default, None, keeps one surface and rejects
junctions.

Fix three parallel defects that the junction tests expose:
- Complete the cohesive label with DMPlexLabelComplete, so that a rank
  that sees a closure point of a surface but none of its facets also
  marks it.
- Reduce the arity of child-parent submesh maps over the communicator,
  so that a rank that sees no broken facet builds the same map.
- Get the subpoint IS in transform_source_points only for a DMPlex
  that has a subpoint map.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbrubeck
pbrubeck force-pushed the pbrubeck/broken-mesh branch from cfae941 to 1172b13 Compare September 28, 2026 23:43
Submesh and BrokenMesh now build their output mesh through
_child_mesh_from_plex(), which DomainDecomposition will also use.

trans_mesh_entity_map() raises NotImplementedError when an entity of the
base mesh has more than one copy on the target mesh, except for the two
sides of a broken facet. Such maps arise from overlapping subdomains.
Without the check, assembly receives a map with several copies per
entity, which a kernel over a single entity cannot use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pbrubeck pbrubeck added the base:main Run this PR using a main (dev) build label Oct 1, 2026
A child plex inherits the pyop2_core, pyop2_owned, and pyop2_ghost labels
of its parent, and mark_entity_classes() keeps existing labels. For
BrokenMesh, whose transform changes the point SF, the inherited ghost
points differ from the leaves of the SF, so the owned sizes and the
global numbering disagree: in parallel, the assembled matrix of a
BrokenMesh space does not match the assembled action. Removing these
labels in _child_mesh_from_plex() lets every child mesh classify its
entities from its own point SF.

For Submesh, the ghost points were already right. On the two-process
mesh of test_submesh_base_entity_maps, the cells of the process without
ghosts are now core rather than owned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adapt broken-mesh maps to PyOP3 while preserving point ancestry, facet-side ordering, and orientation cache updates.

Assisted-by: OpenAI Codex
Filter cohesive cells after each cut and compose the parent point maps
through the filtered meshes. Add regressions for independent jumps on
crossing faults and consistent cohesive labels across MPI ranks.

Assisted-by: OpenAI Codex (GPT-6) <codex@openai.com>
Update split-facet mapping and packing for the mesh indexing changes in main. Keep adaptive multigrid coverage for the transform source points in dmcommon.

Assisted-by: OpenAI Codex (GPT-6) <codex@openai.com>
@pbrubeck
pbrubeck force-pushed the pbrubeck/broken-mesh branch from b4f900e to 259b323 Compare November 28, 2026 00:31
pbrubeck and others added 5 commits November 28, 2026 01:10
Restore the original DMPlex cones after cohesive transforms, preserve existing labels, and select retained cells by their source points. Verify broken facet assembly through the public API and regenerate the fault elasticity demo figures.

Assisted-by: OpenAI Codex (GPT-6) <codex@openai.com>
Retitle the demo "Geophysical cracks and faults with BrokenMesh", open it
with an emphasis block as the other demos do, and remove the background
that is not about Firedrake. Use the same direct solver for both problems,
write the jump as [[u]], and use Constant for the slip parameters.

Keep the plotting code in the appendix, but replace the reference,
deformed and geometry figures with one figure for each problem: the
deformed broken mesh next to the displacement of the ground surface.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the child-to-parent and the two-sided submesh maps in one branch
each, and drop the temporary integral type variable. Reuse utils.unique
and utils.unique_name in BrokenMesh, and fix unique_name, which added the
old name to the name set, so that consecutive calls returned the same name.

Count ridges from the facet cones, and exchange the ridge counts of all
surfaces in one SF reduction and broadcast. Remove the ghost label only in
BrokenMesh, so that Submesh keeps the entity classes from
submesh_correct_entity_classes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MeshTopology.point_sf passed the number of points where StarForest expects
the communicator, so point_sf.comm was an integer in parallel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build the map from a parent interior facet to its two broken copies in its
own cached property, so that the general submesh entity map and
submesh_map_child_parent keep their form on main. Construct the broken mesh
with Mesh directly instead of through a helper shared with Submesh, and rely
on PETSc to reject an invalid label name or subdomain ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

base:main Run this PR using a main (dev) build LLM used An LLM was used in the production of this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants