Skip to content

Refactor periodic utility meshes#4836

Merged
pbrubeck merged 13 commits intomainfrom
connorjward/periodic-dmplex
Mar 31, 2026
Merged

Refactor periodic utility meshes#4836
pbrubeck merged 13 commits intomainfrom
connorjward/periodic-dmplex

Conversation

@connorjward
Copy link
Copy Markdown
Contributor

@connorjward connorjward commented Jan 23, 2026

Summary of changes

  • Use (where possible) DMPlex.createBoxMesh to generate our periodic meshes. This is needed because the current approach that we use results in an invalid DMPlex that cannot subsequently be extruded. This PR is therefore a blocker for pyop3.
  • Uses a DMPlexTransform to perform "crossed", "left" or "right" refinement instead of rolling our own solution.
  • Deprecate PartiallyPeriodicRectangleMesh. It's functionality is totally covered by PeriodicRectangleMesh.
  • Set the 'Face Sets' label of the mesh (the boundary markers) by renumbering the existing one DMPlex provides, instead of performing our own comparison and traversal to rediscover already known structure.

Breaking API changes

  • For a 3D periodic box mesh we currently label all of the boundaries, meaning that the periodic boundary can be used in interior facet integrals. It substantially simplifies the implementation if we don't do this and only label the non-periodic boundaries. Therefore one can no longer do dS integrals along the periodic boundary for 3D box meshes.

Prerequisite PRs

Comment thread .github/workflows/core.yml Outdated
@connorjward connorjward force-pushed the connorjward/periodic-dmplex branch from 2984ac1 to 64d1a00 Compare March 3, 2026 13:59
Comment thread .github/workflows/core.yml Outdated
This is necessary because the previous approach to generating periodic
meshes resulted in a DMPlex with a slightly invalid state that prevents
subsequent transformations (in particular extrusion).

We also avoid manually labelling the boundaries in favour of just renumbering
the existing 'Face Sets' label produced by the DMPlex.
@connorjward connorjward force-pushed the connorjward/periodic-dmplex branch from 792a7c5 to fcf088c Compare March 6, 2026 13:55
Comment thread tests/firedrake/regression/test_periodic_2d.py Outdated
Comment thread firedrake/cython/dmcommon.pyx Outdated
Comment thread firedrake/cython/dmcommon.pyx
Comment thread firedrake/cython/dmcommon.pyx
Comment thread firedrake/utility_meshes.py Outdated
Comment thread firedrake/utility_meshes.py Outdated
Comment thread firedrake/utility_meshes.py Outdated
Co-authored-by: Connor Ward <c.ward20@imperial.ac.uk>
Comment thread tests/firedrake/extrusion/test_variable_layers_numbering.py
Comment thread .github/workflows/core.yml Outdated
@connorjward connorjward marked this pull request as ready for review March 20, 2026 10:13
@connorjward
Copy link
Copy Markdown
Contributor Author

@pbrubeck or @JHopeCollins are either of you able to review this? It looks daunting but the changes aren't actually that huge.

For the tests I have had to reorder some arrays because the numbering is different. The tests are not ideal in this way but I think making more robust tests is out of scope here.

There is still one PETSc fix that I need to have merged but it doesn't change the Firedrake code so this can therefore be reviewed now.

Comment thread .github/workflows/core.yml Outdated
Comment thread firedrake/cython/dmcommon.pyx
Copy link
Copy Markdown
Contributor

@pbrubeck pbrubeck left a comment

Choose a reason for hiding this comment

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

The BC label renumbering could be in its own PR, as it is an API breaking change

@connorjward connorjward requested a review from pbrubeck March 31, 2026 14:26
@pbrubeck pbrubeck merged commit 951bcd2 into main Mar 31, 2026
8 of 14 checks passed
@pbrubeck pbrubeck deleted the connorjward/periodic-dmplex branch March 31, 2026 16:01
sghelichkhani added a commit to g-adopt/g-adopt that referenced this pull request Apr 2, 2026
The firedrake mesh utility refactor (firedrakeproject/firedrake#4836,
merged 31 March 2026) changed how UnitSquareMesh generates triangle
meshes, now using PETSc refine_tosimplex DMPlexTransform instead of
a hand-rolled quad-to-triangle split. The meshes are equally valid but
have different cell ordering, shifting numerical results slightly.

These tests do not import gadopt. They are pure Firedrake/pyadjoint
tests, so the failures on PR #490 were from this upstream change, not
from the solution_old reordering proposed there.
stephankramer added a commit to thetisproject/thetis that referenced this pull request Apr 24, 2026
Changes are due to node ordering in utility meshes since
firedrakeproject/firedrake#4836. In test_hessian_recovery2d and
test_vorticity_calculation2d these are just tolerance tweaks. For the
bottom friction test with bdm-dg I think this has highlighted that the
implicit (vertical) momentum solver using a single ilu(0) sweep
does not work very well for bdm-dg (also rt-dg seems to not be
very stable). Need to find more general solution. In the test, switching
to ILU(1) appears to make it stable again.
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.

2 participants