API: Diagnostics

Mesh checks

check_mesh

check_mesh(mesh::SurfaceMesh) → NamedTuple

Returns a named tuple with:

FieldTypeDescription
n_verticesIntNumber of vertices
n_edgesIntNumber of (canonical) edges
n_facesIntNumber of triangles
closedBoolAll edges have 2 adjacent faces
manifoldBoolAll edges have ≤ 2 adjacent faces
consistent_orientationBoolInterior edges traversed oppositely
euler_characteristicInt$\chi = V - E + F$
warningsVector{String}List of detected problems

euler_characteristic

euler_characteristic(mesh) → Int    # V - E + F

is_closed / is_manifold / has_consistent_orientation

is_closed(mesh) → Bool
is_manifold(mesh) → Bool
has_consistent_orientation(mesh) → Bool

DEC checks

check_dec

check_dec(mesh, geom, dec; tol=1e-10) → NamedTuple

Returns:

FieldDescription
d1_d0_zeroBool: $|d_1 d_0|_\infty < \text{tol}$
d1_d0_max_residualT: \max
lap_constant_nullspaceBool: $|L \mathbf{1}|_\infty < \text{tol}$
star0_positiveBool: all dual areas $> 0$
star1_positiveBool: all cotan weights $> 0$ (may be false for obtuse meshes)
warningsVector{String}

Gauss–Bonnet diagnostic

gauss_bonnet_residual

gauss_bonnet_residual(mesh, geom) → T

Returns $\left|\int_\Gamma K \, dA - 2\pi\chi\right|$. Should be near machine precision for any mesh produced by the built-in generators.

integrated_gaussian_curvature

integrated_gaussian_curvature(mesh, geom) → T    # Σ K_i A_i*

Hodge star quality

star1_sign_report

star1_sign_report(dec) → NamedTuple
FieldDescription
n_entriesTotal number of ⋆₁ diagonal entries
n_nonpositiveCount of entries $\leq 0$
frac_nonpositiveFraction of non-positive entries
min_entryMinimum value (negative if obtuse triangles present)
all_positiveBool

Laplacian comparison

compare_laplace_methods

compare_laplace_methods(mesh, geom) → NamedTuple

Assembles both $L_{\text{dec}}$ and $L_{\text{cotan}}$ and returns:

FieldDescription
norm_inf$|L_{\text{dec}} - L_{\text{cotan}}|_\infty$
norm_frob$|L_{\text{dec}} - L_{\text{cotan}}|_F$
dec_nullspace$|L_{\text{dec}} \mathbf{1}|_\infty$
cotan_nullspace$|L_{\text{cotan}} \mathbf{1}|_\infty$
max_dec_resMaximum residual of DEC eigenvalue test
max_cotan_resMaximum residual of cotan eigenvalue test

On well-shaped meshes norm_inf < 1e-12.


IO

Loading meshes

load_surface_stl(path::String) → SurfaceMesh{Float32}
# Returns Float32 (native STL precision)

load_curve_csv(path::String) → CurveMesh{Float64}
# CSV format: one "x,y" or "x,y,z" coordinate per line

load_curve_points(pts; closed=true) → CurveMesh{T}
# pts: Vector{SVector{2,T}} or Vector{Tuple{T,T}}

See also