Repository navigation
tf overlays: the contour spectrum and contour tree of a field on a mesh - #879
Merged
Merged
Conversation
The FEM demos' Colours editors could not show the contour spectrum or the contour tree: both were computed from volumes only, and the mesh_lab / fe_lab fields reported them unavailable. They now come from the field's own mesh. - cvc::contour_mesh (cvc/volume/contour_mesh.h): a scalar field on a simplicial mesh, one value per point, linear over each tetrahedron, or over each triangle of a surface. - mesh_contour_spectrum_builder and compute_contour_spectrum(contour_mesh): on tetrahedra, the grid version's per-tetrahedron integrals with each tetrahedron's exact gradient. On triangles, exact per-triangle integrals: the contours' length, the area below and above, and |grad f|^2 along them. Resumable; stepping changes no bit. - mesh_contour_tree_builder and compute_contour_tree(contour_mesh): Carr's join / split / merge over the graph of the elements' edges, resumable in every phase (a bottom-up merge sort). On a grid's own tetrahedra it builds exactly the grid builder's tree. NaN points are left out with their edges, and pieces get a tree each. A domain whose level sets loop still gives a tree. - overlay_job, compute_overlays and schedule_overlays take a mesh. overlay_options::has_range computes the layers over a given range. - mesh_lab / fe_lab: an editor's request starts overlay tasks on the state_exec scheduler (cooperative where there are no threads) over the published range, one per layer. The tree is built on the values clamped to that range, which keeps its components there and drops the far-outlier extrema, and capped at 200 nodes. New values cancel the tasks and clear the layers. fe_lab's elements view (one value per element) reports them unavailable. Tests: mesh_contour_test (13: against the grid tree on random data with plateaus, exact linear-field spectra on cubes and squares, stepping, loopy and disconnected domains, errors, a job and a scheduled task), and cvcgl_ariadne_realize (both FEM nodes publish the layers on request).
transfix
force-pushed
the
feat/mesh-contour-overlays
branch
from
October 29, 2026 23:02
79fb85e to
d974a66
Compare
transfix
enabled auto-merge (squash)
October 29, 2026 23:12
This was referenced Oct 30, 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.
Rebased onto master after #878 merged (f715017).
The FEM demos' Colours editors couldn't show the contour spectrum or contour tree. Both overlays were computed from volumes only, so on mesh_lab and fe_lab fields #878 marked them unavailable. With this PR, they're computed on the field's own mesh.
Library (
cvc, no GL):cvc::contour_mesh(cvc/volume/contour_mesh.h): a scalar field on a simplicial mesh, one value per point, linear over each tetrahedron (or over each triangle of a surface).mesh_contour_spectrum_builderandcompute_contour_spectrum(contour_mesh):mesh_contour_tree_builderandcompute_contour_tree(contour_mesh):overlay_job,compute_overlaysandschedule_overlaysaccept a mesh.overlay_options::has_rangecomputes the layers over a given range.FEM nodes (
mesh_nodes.cpp): when an editor asks for these layers (Display ▸ Contour spectrum / Contour tree), the node starts overlay tasks on the app's state_exec scheduler: cooperative slices on single-threaded wasm, the background pool where threads exist. There's one task per layer, computed over the publishedfield_colors.rangeso the layers line up with the histogram.Tests (Windows, MSVC; all pass):
mesh_contour_test(13 tests):overlay_jobmatches the one-shot result however it's stepped;cvcgl_ariadne_realize: both FEM nodes publish a 256-sample spectrum and a tree on request, and keep them across a recolour.contour_tree_test(40),contour_spectrum_test(25),tf_overlays_test(18),tf_overlay_tasks_test(15),cvcgl_tf_editor,cvcgl_tf_binding,cvcgl_fe_interval.Visual check: arigl snapshots of mesh_lab.ari with both Colours editors showing every layer:
Not covered by a test: the elements-view note.
Docs:
docs/TRANSFER_FUNCTIONS.md§5 ("On a mesh") and §6 (field colours), anddocs/ARIADNE.md"Field colours".