Mesh
Mesh is a 2D simplicial complex: a collection of vertices, oriented edges, and
triangles, together with their primal and dual volumes needed by the Hodge star.
Summary
| Property | Value |
|---|---|
| Struct | Mesh |
| Vertices | positions in |
| Edges | oriented pairs with |
| Triangles | oriented triples |
| Primal volumes | Edge lengths ; triangle areas |
| Dual volumes | Dual edge lengths (circumcentric or barycentric); dual vertex areas |
Construction
Uniform grid
use cartan_dec::Mesh;
// 4x4 grid on [0,1]²: 16 vertices, structured triangulation
let mesh = Mesh::unit_square_grid(4);
println!("Vertices: {}", mesh.n_vertices()); // 16
println!("Edges: {}", mesh.n_edges()); // 40
println!("Triangles: {}", mesh.n_triangles()); // 18From raw geometry
use cartan_dec::Mesh;
let vertices: Vec<[f64; 2]> = vec![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]];
let triangles: Vec<[usize; 3]> = vec![[0, 1, 2], [1, 3, 2]];
let mesh = Mesh::from_triangles(vertices, triangles);Fields
// Public fields
mesh.vertices: Vec<[f64; 2]> // vertex coordinates
mesh.edges: Vec<[usize; 2]> // edge endpoint indices (oriented)
mesh.triangles: Vec<[usize; 3]> // triangle vertex indices (CCW)
// Key methods
mesh.n_vertices() // -> usize
mesh.n_edges() // -> usize
mesh.n_triangles() // -> usize
mesh.triangle_area(t) // -> f64: area of triangle t
mesh.vertex(i) // -> [f64; 2]: coordinates of vertex iNumerical Notes
Orientation: edges are stored with the smaller index first. Triangles are stored in counter-clockwise (CCW) order to ensure positive triangle areas and correct exterior derivative signs.
Well-centered condition: the Hodge star is positive definite only when the
mesh is well-centered (circumcenter inside each triangle). unit_square_grid
produces a well-centered mesh; custom meshes from from_triangles are not
automatically checked.
Memory layout: vertices, edges, and triangles are stored as plain Vec
arrays (no adjacency lists). The ExteriorDerivative and Operators structs
precompute adjacency during construction.
Applications
- Uniform grid for heat equation and Laplacian studies
- Custom triangulated domain for Q-tensor / active nematics simulation
- Benchmark meshes for DEC operator testing