🔺 Meshing
Automatic Delaunay triangulation with Ruppert refinement — fast, high-quality, running entirely in your browser via WebAssembly.
The spade Mesher
ThermX uses spade, a Constrained Delaunay Triangulation (CDT) engine written in Rust and compiled to WebAssembly (WASM). The spade WASM binary is only 185 KB — small enough to ship inline — and runs at near-native speed in both the browser and desktop app.
The meshing algorithm is based on Ruppert's refinement, which iteratively improves mesh quality by inserting new Steiner points until all triangles meet the user-specified angle and area constraints.
Generating a Mesh
- Complete your geometry (all regions drawn, no overlaps)
- Assign materials and boundary conditions
- Open the Mesh tab in the right panel
- Adjust quality parameters if needed (defaults work well for most models)
- Click Generate Mesh
The mesh is generated in a background Web Worker so the UI remains responsive. For typical building component cross-sections, meshing takes under one second.
Quality Parameters
Start with defaults. If results show large temperature gradients in a region, reduce max edge length there or set a max area constraint and remesh. For thin insulation layers, ensure min edge is smaller than the layer thickness.
Dual-Slider Controls
The min/max edge length sliders are linked: the minimum can never exceed the maximum. Both sliders use a logarithmic scale so that fine control is available at small values (below 2 mm) while still allowing coarse values up to 50 mm.
Real-Time Mesh Preview
After meshing, the canvas shows the triangulation overlaid on your geometry. Triangles are color-coded by quality:
- Green — High-quality triangles (angles near 60°)
- Yellow — Acceptable quality
- Red — Poor quality (sharp angles); consider tightening the min angle constraint
Hover over any triangle to see its area, minimum angle, and element index.
Mesh Statistics
After generation, the Mesh panel shows:
- Total number of triangles
- Total number of nodes
- Minimum and maximum triangle angles
- Generation time
Technical Details
| Component | Details |
|---|---|
| Algorithm | Constrained Delaunay + Ruppert's Refinement |
| Implementation | spade (Rust crate) |
| Runtime | WebAssembly (WASM), 185 KB binary |
| Threading | Runs in a Web Worker (non-blocking) |
| Constraints | All geometry edges are preserved as constrained edges |
| Material boundaries | Automatically preserved — no triangle spans multiple materials |
Common Issues
Meshing fails or hangs
This usually means geometry has overlapping regions or extremely short edges (degenerate geometry). Check for overlaps using Check Geometry and ensure no vertices are placed closer together than the min edge length.
Too many elements, slow solve
Increase the max edge length or the max area. For a quick check, use a coarse mesh; for final results, refine.
Poor quality near thin layers
Reduce the min edge length below the layer thickness. Alternatively, increase the min angle to force more equilateral triangles in those regions.