Repository navigation
FlipBoundaryOrientation: reverse the winding with Mesh.with_cells - #2268
Merged
peterdsharpe merged 3 commits intoNov 13, 2026
Merged
Conversation
…only reordered (NVIDIA#2266) * Keep measures of reordered cells in Mesh.with_cells A row that only reorders its own vertices, such as a winding flip, is the same simplex: it now keeps its effective measure, cached area, and cached centroid bitwise, instead of being rescaled by float32 roundoff in the area ratio or raising on a zero-area cell with a nonzero measure. Rows whose vertex set changes keep the area-ratio transfer. Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com> * Accept unsigned replacement cells in Mesh.with_cells The reordered-row check compared the raw replacement with the mesh's int64 cells, and PyTorch cannot promote uint16, uint32 or uint64 with int64. Compare result.cells, which the constructor has normalized. Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com> * Make the dtype comment in Mesh.with_cells exact Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com> * Document the caches Mesh.with_cells keeps, and widen its tests Returns and Notes now say which caches the result holds without keep, and that they are computed eagerly for all cells. _transfer_cell_measures documents how unchanged indexes rows when parents is given, and says why it caches the old area bits. New tests cover a compiled flip, an empty mesh, keep=("cell", "areas"), and CUDA for the measure tests; the centroid tests use a sentinel and the sliver test checks the cached area, so each fails if its value is recomputed. Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com> --------- Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com>
Since NVIDIA#2266, Mesh.with_cells keeps the effective measure of each cell whose vertices are only reordered, with the area it came from, so the transform uses it instead of building a new Mesh. A flipped mesh with effective measures now also keeps each cell's cached area bit for bit, where recomputed float32 areas differ between the two vertex orders. Signed-off-by: Peter Sharpe <peterdsharpe@gmail.com>
Collaborator
Author
|
/ok to test 057b878 |
Contributor
CODEOWNERS review mapCurrent for commit ⏳ @coreyjadams — 2 file(s)
⏳ @negin513 — 2 file(s)
⏳ @peterdsharpe — 1 file(s)
Comment |
Collaborator
Author
|
/ok to test a9c8477 |
Contributor
|
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThis PR preserves effective cell measures and their matching areas when cell vertices are reordered, and routes
No actionable issues found. Reviews (1) · Last reviewed commit: "FlipBoundaryOrientation: reverse the win..." · Reviewed by Greptile |
negin513
reviewed
Nov 13, 2026
negin513
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR targets
2.3.0-rc, which lacks #2266, so it also backports #2266. In this PR,mesh.py,measure.pyand four mesh test files matchmainbyte for byte, where #2266 was reviewed.CHANGELOG.mdgains #2266's entry.On
2.3.0-rc,FlipBoundaryOrientation, added in #2261, reverses a winding by building a newMesh. There,Mesh.with_cellsrescales the effective measures of reordered cells and can raise on zero-area ones. The backported #2266 makes it keep each measure, and its area, bit for bit. The transform now calls it.A flipped mesh with effective measures now also keeps each cell's cached area bit for bit, outside tracing and autograd. Before, its areas were recomputed in the new vertex order, which in float32 differs from the area each measure came from. Normals named in
normal_fieldsare still negated, and the normals cached for the old winding are still dropped.This PR's own change removes 10 lines and adds 7 in
transforms.py, plus one test. The test flips a sphere with effective measures and checks its measures and areas bit for bit, where recomputed areas differ. The datapipes transform tests and the unified aero recipe's tests pass.Checklist
Dependencies
#2266, which this PR backports to
2.3.0-rc.Review Process
All PRs are reviewed by the PhysicsNeMo team before merging.
Depending on which files are changed, GitHub may automatically assign a maintainer for review.
We are also testing AI-based code review tools (e.g., Greptile), which may add automated comments with a confidence score.
This score reflects the AI’s assessment of merge readiness and is not a qualitative judgment of your work, nor is
it an indication that the PR will be accepted / rejected.
AI-generated feedback should be reviewed critically for usefulness.
You are not required to respond to every AI comment, but they are intended to help both authors and reviewers.
Please react to Greptile comments with 👍 or 👎 to provide feedback on their accuracy.