Make mesh.cell_size() local and partition independent - #692
Conversation
…#687) Adapt only the mesh-size correction from lmoresi's 68e545f on feature/navier-stokes-supg; do not import Navier-Stokes or other branch changes. Cache _radii_own from current DM vertex coordinates and use it for mesh.cell_size(). Preserve the legacy kd-tree radius arrays and global timestep/mesh-motion consumers. Use coordinate-section offsets and the full vertex stratum so the own-cell RMS definition also handles hexahedra, which have eight vertices but six faces. Correct the field documentation and Nitsche mechanism tests for the new definition; retain physical solve tolerances and use the exact nearest-centroid <= own-centroid ordering instead of an arbitrary approximate-equality tolerance. Add a first-failing independent geometry/deformation regression for triangles, tetrahedra, quadrilaterals and hexahedra plus a regular-square analytical control. Before: four failures in serial and on eight ranks. After rebuild: 21 passed/one expected skip serial (22.90 s), 22 passed on eight ranks (40.45 s), covering Nitsche solves, radius accessors, frozen PC2 migration and memory/disk snapshots. Own-cell geometry error is zero in these tests; style and whitespace gates pass.
|
Reviewed by measurement. The fix works, exactly as claimed, and the defect The fix does what it saysPer-cell values gathered and compared across rank counts on the same mesh
So the new field is bit-identical across partitions and the old one is not. The gap: the property is never checked at more than one rank count
What they assert is a within-rank oracle: each cell's size matches its own This is the shape that has bitten this repo twice in the last month. #675 was Concretely: a Two smaller points#687 duplicates #569 (15 August), which is still open and carries something Scope is right. Leaving Nothing here blocks the approach. The fix is correct and I would merge it with a |
|
Follow-up on "why the scope is narrow", since the obvious next question is
Timesteps are not currently affected, and the reason matters. Every I first measured a ~1e-5 spread in But the insulation is incidental, not structural. The min is stable because What is already partition-dependent today, and is not fixed by this PR:
So the narrow scope is defensible for One more, minor: the None of this needs to be in this PR. It is the follow-on issue, and #569 is |
|
Filed #694 for the other half, with your ruling recorded: The fix is half-built here — Not asking for it in this PR. The scope here is right; #694 is the follow-on. |
|
One naming request before this lands, and it is worth doing now because private
So Neither field is about rank ownership. Both are per-cell local arrays. The
A nomenclature that says that, per Charter §3 ("names state what a thing IS"):
Whatever is chosen, #694 will inherit it: the fix there is pointing |
Rename the new per-cell geometric radius cache from _radii_own to _cell_radii so the name describes cell geometry rather than rank ownership. Update the focused Nitsche and deformation checks accordingly.\n\nAdd an enumerated parallel regression that gathers owned-cell centroid/radius pairs and compares the complete sorted table with a fresh single-rank run on the same cached Gmsh mesh. This directly guards the rank-count-independence claim at np=2, np=4 and np=8 instead of relying only on within-rank geometric identities.\n\nValidated locally with 9 focused serial tests and the new MPI test at 2, 4 and 8 ranks.
|
Addressed the requested merge gap in
Local validation after rebuilding the branch:
This directly tests the title claim across rank counts; the existing independent vertex-geometry oracle remains as the separate correctness/deformation check. The practical Nitsche consequence remains documented in |
|
For sequencing context, this fix is also the direct cause of #689's current sole CI failure ( |
Remove the local_h=False workaround from the boundary-normal MPI regression now that Mesh.cell_size() is partition independent. The test again exercises the public local_h=True default and compares its Nitsche solve with a fresh serial process.\n\nRecord the user-visible consequence in the development changelog: the rank-local centroid kd-tree moved the default Nitsche velocity answer by 6.6e-3, while the cell-geometry replacement is identical cell by cell from one through eight ranks.\n\nValidated the focused Nitsche regression at 2, 4 and 8 Open MPI ranks (10.99 s, 7.31 s and 9.60 s respectively).
|
Thanks. Consolidated answers and the resulting changes:
The branch is pushed at |
Summary
Fixes #569 and fixes #687 by making
Mesh.cell_size()a per-cell geometric quantity that is independent of MPI partitioning.The previous field used
self._radii, whose nearest-centroid kd-tree contains only centroids held by the current rank. Near partition boundaries, the nearest available centroid can therefore change with rank count. Nitsche penalties and SUPG stabilization terms built frommesh.cell_size()consequently changed with the partition.Change
_cell_radii; the name describes cell geometry and does not overloadown/owned, which elsewhere denotes MPI-rank ownership._cell_radiionly formesh.cell_size()and refresh its field after mesh deformation through the existing reinitialization path.cell_size()and Nitsche test documentation to state the exact definition and the default Nitsche local-hconsequence.Why the scope is narrow
This does not redefine
get_min_radius(),get_max_radius(), orget_mean_radius(). It corrects only the local field consumed by spatially varying stabilization and penalty terms. Follow-up issue #694 tracks the global accessor contract.Regression coverage
hmagnitude, deformation refresh, and free-slip solve checks.tests/parallel/regression that gathers every owned-cell(centroid, cell radius)row and compares the complete sorted table with a fresh np=1 process using the same cached Gmsh mesh.Validation
The Stokes case emits the existing expected GAMG fallback warning because its tiny mesh has no multigrid hierarchy; all assertions pass.
This is split from #689 so the generic mesh-size correction can be reviewed and merged independently of Eulerian SUPG transport.
Underworld development team with AI support from Claude Code