Repository navigation
Prevent excessive memory use when smoothing large meshes - #65
Open
neumann-alexander wants to merge 1 commit into
Open
neumann-alexander wants to merge 1 commit into
neumann-alexander wants to merge 1 commit into
Conversation
neumann-alexander
marked this pull request as ready for review
October 29, 2026 13:51
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.
Problem
Mesh refinement can run out of memory on large, densely sampled surfaces. We encountered this on a real mesh with approximately 960,000 triangles, where refinement exhausted roughly 128 GiB of available RAM.
The problem is in
smooth_offset_field(): it obtains and retains radius-neighbor lists for every triangle at once. On a dense mesh, each triangle can have many neighbors, so these lists can consume far more memory than the mesh itself.Why batching fixes this
Smoothing one triangle requires its neighbors and the previous iteration’s offsets—not the neighbor lists for every other triangle.
This change queries and processes consecutive batches of triangles, releasing each batch’s neighbor lists before requesting the next. Every triangle is still processed against the complete mesh. There is no subsampling, smaller smoothing radius, or approximate neighbor search.
The distance weights, neighbor ordering, and separation between previous and next iteration values are preserved. Batching changes how much temporary data is retained, not the intended calculation.
Configuration
Adds a positive-integer setting:
Existing configurations inherit this default. Invalid values are rejected before expensive refinement work.
128 was selected using the large mesh because it reduced memory without an observed runtime penalty:
These are single-run, standalone smoothing measurements—not whole-workflow memory requirements. Memory still depends on mesh density and smoothing radius; batching is not an absolute RAM cap.
Validation
Validation was performed outside the repository; no repository test files were added or modified.
Scope and limitations
The change is limited to batching, configuration, and input validation. It does not alter scientific parameters or introduce unrelated upstream changes.
Numerical equivalence was verified for smoothing; a complete old-versus-new large workflow comparison was not possible because the original operation exhausted available memory. A fresh Conda dependency resolution/build was not tested.
AI assistance: An AI coding agent proposed the batching approach, implemented the change, and executed the reported validation. The human contributor approved the approach and directed the work.