Repository navigation
TriWild: tracked winding number per region, input winding numbers only when needed; jse and polysolve with cheaper validation and solves - #1193
Merged
Conversation
filter "tracked" evaluated the winding number of the tracked curves at every face's centroid, an atan2 summed over every curve edge: faces times edges, and on 2D inputs of a few thousand triangles with a few hundred curve edges, about a fifth of the run. For closed curves the winding number is constant on each connected set of faces that no curve edge separates, so it is now evaluated once per such region, at the centroid of its first face, and given to all its faces. Curves that are not closed, whose winding number varies off them, are still evaluated face by face. Only the inside test reads the value (it is not written out), so the same faces are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
jse validated a JSON against its specification by copying, for every node of the input, every rule of the specification. Each component call validates its parameters, and every polysolve solver created for the vertex smoothing -- one per mesh -- validates its own four times (the nonlinear parameters, and the linear ones for each of DenseNewton's three strategies): 40 ms per solver, the time of a whole TriWild run on a small input. With json-spec-engine#9 a polysolve solver is created in 0.5 ms, and the validated and defaulted JSON is byte-identical. Pinned at the PR's head; move to its merge commit once merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
The vertex smoothing creates one polysolve solver per mesh, and creating one validated its parameters with jse every time: with polysolve#131 a solver created again with the same parameters skips the validation (0.02 ms instead of 41 ms; the first one still validates), and minimize() allocates and times less (0.74 instead of 1.02 us for a two-unknown Newton solve). The iterates are the same. Pinned at the PR's head; move to its merge commit once merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
json-spec-engine#9 and polysolve#131 are merged; the merge commits have the same trees as the heads pinned before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
…lters "tracked" and "flood"
The per-input winding numbers (the wn_<i> fields) were skipped only under
filter "none". Filters "tracked" and "flood" do not read them either: they
were computed, an atan2 per face and input segment, for output fields
nobody asked for, about a tenth of a run on small 2D inputs. They are now
computed for filter "input", which keeps the faces by them, and with
skip_winding_number false, as the tutorial already says ("leaves them out
when no filter needs them"). skip_winding_number is true by default, so
filters "tracked" and "flood" no longer write the wn_ fields unless it is
set to false.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF
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.
Four changes that make small TriWild runs cheaper: two in TriWild, and two dependency pins. Three of them leave every output byte-identical. The fourth stops writing output fields nobody asked for, the
wn_*fields under filters"tracked"and"flood", unlessskip_winding_numberis false.Where the time went
Sampled on a batch of small 2D inputs meshed through the memory route with
filter: "tracked"and the defaultnum_threads: 0: 69 TriWild calls of a few hundred to a few thousand triangles, 49k triangles in all, 25.2 s. The batch uses #1188's options, so it was measured with #1188 applied, before and after.filter: "tracked")atan2per face and curve edgeSolver::createwn_*fields)"tracked"although only filter"input"reads themminimize()Changes
TriWild: the tracked winding number once per region (
TriWildMesh::compute_tracked_winding_number). When the oriented tracked curves are closed, their winding number is constant on each connected set of faces that no curve edge separates. It is evaluated once per such region, at its first face's centroid, instead of at every face. Curves that are not closed are still evaluated face by face. Only the inside test reads the value, which is not written out.jse pinned at
mainwith Index the rules by pointer instead of copying them for every node (~150x faster validation) geometryprocessing/json-spec-engine#9 (merged). Validation no longer copies the specification for every node of the input, about 170× faster with byte-identical results. A polysolve solver is now created in 0.5 ms instead of 43 ms, and each component call validates its parameters in well under a millisecond.polysolve pinned at
mainwith Cheap repeated Solver::create, and a lighter minimize() for small problems (results unchanged) polyfem/polysolve#131 (merged). Creating a solver again with the same parameters skips their validation (0.02 ms).minimize()allocates and times less: 0.74 µs instead of 1.02 µs for a 2-unknown Newton solve, with the same iterates.TriWild:
skip_winding_numberalso skips the input winding numbers under filters"tracked"and"flood". Neither filter reads them; until now they were skipped only under"none". They are still computed for filter"input", which keeps the faces by them, and wheneverskip_winding_numberis false. The default is true, so with"tracked"or"flood"thewn_*fields are now written only on request. The tutorial already described this behaviour ("leaves them out when no filter needs them"); the spec's doc andtest_component_ionow say so too.The same batch takes 15.6 s instead of 24.9 s: about 3.3 s from (1), 4.4 s from (2), 0.4 s from (3) and 1.5 s from (4).
Identical outputs
Every output below was compared byte for byte; reports were compared without their timings.
integration_tests.json), before and after:main;tetwild_crownandtetwild_octocatwere run withnum_threads: 0, because with 10 threads they differ from run to run onmainitself;simwild_tight_seal_geom_*configs fail onmainas well: they use an optionmaindoes not have yet.challenging_triwild_*configs and the 4triwild_*ones, run withfilter: "tracked", plustriwild_collectionwithfilter_inputs: all outputs identical (.msh,.vtu, envelope, surface, report). With (4) this holds whenskip_winding_numberis false; with the default the only difference is the missingwn_*fields.ctest296/296, with the pins at the merge commits andmain(tight_seal_geom: clean up comments #1187) merged in. The jse and polysolve PRs carry their own identity harnesses: 1,492 inputs and 8,767 solves.Not done
m_solverslot away from topological offset, which sets its own stopping criteria on it.🤖 Generated with Claude Code
https://claude.ai/code/session_01ULwCy3KGG3sBouB7ZLaXwF