Skip to content

examples: fem_gallery renders FEM, surface and LBIE mesh results; docs/FEM_GALLERY.md - #803

Merged
transfix merged 5 commits into
masterfrom
examples/fem-gallery
Oct 27, 2026
Merged

transfix merged 5 commits into
masterfrom
examples/fem-gallery

Conversation

@transfix

Copy link
Copy Markdown
Owner

Stacked on #802. That PR fixes LBIE's hexahedron decoding and the scaled Jacobian, and the hex pictures here need both. This PR's base is fix/lbie-hex-corner-order; GitHub retargets it to master once #802 merges.

What's in it

examples/cvcgl/fem_gallery.cpp

A synchronous, offscreen CLI: one run renders one picture, and it never races a background job the way an .ari scene does.

  • Input and solid: load a surface mesh or a scalar volume. The solid is the inside of an SDF (SDF_IGL) or a CT isovalue.
  • Meshing: LBIE tet-meshes the solid.
  • Volume problems (cvc::fem): Poisson, heat (backward Euler from a hot floor), or Neumann Laplacian eigenmodes.
  • Surface problems (mesh_ops / fem on the surface): mean curvature, heat-method geodesics, or Laplace–Beltrami modes.
  • View: the field is drawn on the translucent outer surface plus a planar cut. For a surface mesh, the solution is sampled onto the input surface, which hides the tet mesh's grid-aligned boundary.
  • --problem mesh: draws LBIE's tetrahedra or hexahedra themselves as a cutaway. Elements beyond the plane stay whole and are outlined. They are coloured by size (octree level) or quality (minimum dihedral angle, scaled Jacobian).
  • --iso2 / --improve: reach cvc::tetrahedralize2 and LBIE's improvement passes.

docs/FEM_GALLERY.md

20 renders, regenerated by examples/cvcgl/fem_gallery_docs.sh. The images are 800×600 JPEGs in docs/img/fem-gallery, about 550 KB in all. The datasets are the built-in bunny, TexMol's head.off and VolRover's vh4.rawiv CT.

Heat, 40 steps Solid's mode 1 CT body: heat Surface mode 9 Hexes by quality

Wiring

  • examples/CMakeLists.txt builds fem_gallery natively (not under Emscripten) and installs it with the other example CLIs.
  • The libigl roadmap links the gallery.

Not shown yet

The page lists these LBIE problems found while making it. They are follow-ups for the mesher, not this PR:

  • Tetrahedra: the tet boundary is a grid staircase, where the hex boundary is fitted.
  • Geometric flow on tets: it drops the minimum dihedral angle from 26.6° to 0.75°.
  • Interval meshes: tetrahedralize2 leaves sliver fans and holes.
  • Hexahedra on the head and the CT: adaptive hexahedralization collapses about half the hexahedra.

Verification

  • Built on Windows (MSVC Release, shared, ImageMagick ON, CVC_ENABLE_LIBIGL=ON).
  • All 20 renders were regenerated with the script from this tree and checked by eye.
  • clang-format is clean on the changed lines.

…caled Jacobian is 1

geoframe stores a hexahedron as its six faces, and LBIE winds the second
face against the first (Octree::add_hexa); saveHexa and the optimizer in
octree.cpp read the top corners from it as v5 v4 v7 v6. The geoframe_adapter
read and wrote both faces in plain order, so every hexahedron from
cvc::hexahedralize was twisted (corner k + 4 not over corner k), and
geometry::quality_improve handed LBIE's optimizer twisted hexahedra. The older
convert() path (decode_hexs_from_quads) had it right. The adapter now reads and
writes LBIE's layout: on the bunny at 65^3 the mean scaled Jacobian goes from
~0 to 0.85, with 97-99% of the hexahedra right-handed at every corner.

hex_scaled_jacobian divided the centre Jacobian by the space diagonal cubed, so
a unit cube scored 1/sqrt(27) = 0.024, though its docs say 1 and
filter_hexs_by_quality's default threshold of 0.2 rejected every cube. It is now
the worst corner's determinant of unit edges (the Verdict definition): 1 for a
box, 1/sqrt(5) for a cube sheared by twice its height, -1 for its mirror image.
…s/FEM_GALLERY.md

fem_gallery is a synchronous offscreen CLI: load a surface mesh or a volume,
tet-mesh the solid (SDF_IGL + LBIE, or a CT isovalue), solve Poisson, heat or
Neumann eigenmodes with cvc::fem (or curvature, geodesics and Laplace-Beltrami
modes on the surface), colour the boundary and a planar cut, and write a PNG.
For a surface mesh the solution is sampled onto the input surface, which hides
the tet mesh's grid-aligned boundary. --problem mesh shows LBIE's tetrahedra or
hexahedra themselves, cut away and coloured by element size (octree level) or
quality (minimum dihedral angle, scaled Jacobian); --iso2 and --improve reach
cvc::tetrahedralize2 and LBIE's improvement passes.

docs/FEM_GALLERY.md shows 20 renders (bunny, the TexMol head, the VolRover vh4
CT), and examples/cvcgl/fem_gallery_docs.sh regenerates them. The page lists
what LBIE does not do well yet, so it isn't shown: staircase tet boundaries,
geometric flow on tets, tetrahedralize2's slivers, collapsed adaptive hexahedra
on the head and CT.
… --improve out are fixed by #808

The tetrahedral staircase boundary, geometric flow wrecking tetrahedra, tetrahedralize2's
broken layers and the collapsed hexahedra on the head and the CT are all fixed in #808. The
pictures and element counts here predate it and change once both land.
#802 (its base) landed on master as a squash; this merges master on the branch's real base, fc9220a, so #803 carries only its own changes.
@transfix
transfix changed the base branch from fix/lbie-hex-corner-order to master October 26, 2026 22:29
@transfix

Copy link
Copy Markdown
Owner Author

Retargeted to master after #802 merged; reopening to run master's PR checks.

@transfix transfix closed this Oct 26, 2026
@transfix transfix reopened this Oct 26, 2026
@transfix
transfix merged commit 5f16394 into master Oct 27, 2026
34 of 36 checks passed
transfix added a commit that referenced this pull request Oct 27, 2026
#827 (tf_editor) and this branch both rework fe_lab. fe_lab keeps #827's mesh.region
(solid | interval), its interval props and tetrahedralize_interval; this branch's mesh.interval
flag becomes region interval (fe_controls' Mesh region combo, fem_gallery.ari, the realize test,
ARIADNE.md). Everything else here stays: hex elements, source loading, placement, quality stats.

fe_lab now loads its volume on its lane, so the transfer-function binding follows each load
(tf_binding_options::volume_source): until a volume arrives there is no range or overlay and no
bound key is written; on a new range the followed bars move to the keys' values, which are never
rewritten for it, and nothing re-meshes. mesh.isovalue2's default waits for an SDF's range.
cvcgl_tf_binding checks this with an SDF source loaded after realize and then reloaded.

docs/FEM_GALLERY.md: #803 landed as a squash of this branch's base, so this branch's version
(#803's plus its own edits) is kept.
@transfix
transfix deleted the examples/fem-gallery branch October 29, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant