fem.simmesh.SimMesh

fem.simmesh.SimMesh(
    name,
    resolution,
    domain=None,
    bounds=None,
    size=None,
    padding=0.1,
    method=MeshMethod.HEX,
    mesher=TetMesher.TETGEN,
)

A declarable, named meshing intent — the scene program’s mesh object.

Attributes

Name Type Description
name str Mesh identifier (unique within a scene program; studies refer to it via mesh="<name>").
resolution Any Sampling-lattice cells per axis (positive int or triplet). Elements for method="hex"; the DC extraction grid for the tet methods (see the module docstring for the honest mapping).
domain Any Optional SDF (or plain callable field) selecting which part of the scene participates: when set, :meth:build meshes this field instead of the scene SDF handed to solve/build.
bounds Any Lower corner of the meshing box, or None to derive it from the meshed field automatically (coarse inside-scan + padding).
size Any Extent of the meshing box; None exactly when bounds is.
padding float Extra margin per side used only by the automatic bounds scan.
method MeshMethodLike Meshing method — a :class:~cadjoint.enums.MeshMethod or its plain string spelling: "hex" (voxelize+snap HEX8, the fast default), "tet4" (DC surface -> TetGen TET4), or "tet10" (the TET4 mesh promoted to quadratic tets — the quality path). Normalised to the enum on construction.
mesher TetMesherLike Which volume mesher fills a tet4/tet10 mesh — a :class:~cadjoint.enums.TetMesher or its string spelling. "tetgen" (the default) is TetGen on the dual-contour surface, sized by the lattice, and every node follows the design through :func:~cadjoint.fem.motion.recompute_tet_points. "gmsh" is :func:cadjoint.fem.gmsh.sdf_gmsh_tet_mesh — the same surface handed to Gmsh’s HXT as an STL, sized by the part, with second-order midsides on a reparametrised surface and every node tagged with the patches that own it. A Gmsh mesh’s nodes follow the design only through the node_map plugin kind, which is the private tier’s: without it the mesh is frozen geometry and :attr:frozen_geometry says so. Ignored for method="hex".

Methods

Name Description
build Extract (or reuse) the volume mesh for the current parameters.
describe JSON-ready declaration payload: everything the viewer displays.
grid The sampling grid this mesh uses (resolving automatic bounds).
inspect JSON-ready inspection summary of the built mesh.
quality Per-element quality metrics of the built mesh.

build

fem.simmesh.SimMesh.build(sdf=None, *, rebuild=False)

Extract (or reuse) the volume mesh for the current parameters.

The result is cached on the instance and reused while the meshing parameters and the meshed field object stay the same; pass rebuild=True after mutating the field’s parameter values in place to force re-extraction.

Parameters

Name Type Description Default
sdf Any Scene SDF object or callable field; ignored when the mesh declares a domain, required otherwise. None
rebuild bool Discard the cached mesh and re-extract. False

Returns

Name Type Description
HexMesh | TetMesh | CutMesh The extracted :class:~cadjoint.fem.hexmesh.HexMesh
HexMesh | TetMesh | CutMesh (method="hex") or :class:~cadjoint.fem.tetmesh.TetMesh
HexMesh | TetMesh | CutMesh (method="tet4"/"tet10"; requires tetgen). Tet
HexMesh | TetMesh | CutMesh extraction runs :func:~cadjoint.fem.tetmesh.sdf_to_tet_mesh’s
HexMesh | TetMesh | CutMesh refinement ladder, which tries exact sharp-feature DC placement
HexMesh | TetMesh | CutMesh and the more robust Tikhonov placement at every rung and
HexMesh | TetMesh | CutMesh records what it tried on mesh.refinement; when no rung
HexMesh | TetMesh | CutMesh works the TetGen error propagates, naming both ends of the
HexMesh | TetMesh | CutMesh ladder. The tet grid must fully contain the zero surface
HexMesh | TetMesh | CutMesh (unlike voxelization, DC needs the closed boundary).

describe

fem.simmesh.SimMesh.describe()

JSON-ready declaration payload: everything the viewer displays.

The domain entry records the selected object by its name attribute when it has one (the viewer patches it by name) plus its type; meshes without a domain report None.

grid

fem.simmesh.SimMesh.grid(sdf=None)

The sampling grid this mesh uses (resolving automatic bounds).

For method="hex" the grid cells are the candidate elements; for the tet methods it is the DC extraction lattice.

Parameters

Name Type Description Default
sdf Any Scene SDF, needed only when the mesh has no domain and automatic bounds must scan the field. None

inspect

fem.simmesh.SimMesh.inspect(sdf=None)

JSON-ready inspection summary of the built mesh.

Builds the mesh first if needed (same caching as :meth:build).

Returns

Name Type Description
dict[str, Any] {"name", "method", "nodes", "elements", "bounds": {"min", | | | dict\[str, Any\] | "max"}, "grid": {"origin", "spacing", "cells"}, "quality": | | | dict\[str, Any\] | {...}} where each quality entry is a {"min", "mean", | | | dict\[str, Any\] | "max"} summary over elements. The shape is
dict[str, Any] method-agnostic; only the metric names under "quality"
dict[str, Any] differ (:meth:quality), so a stats display can iterate them.

quality

fem.simmesh.SimMesh.quality(sdf=None)

Per-element quality metrics of the built mesh.

Builds the mesh first if needed (same caching as :meth:build).

Returns

Name Type Description
dict[str, np.ndarray] {"scaled_jacobian": (C,), "aspect_ratio": (C,)} float64
dict[str, np.ndarray] arrays for hex meshes (see
dict[str, np.ndarray] func:~cadjoint.fem.quality.scaled_jacobians /
dict[str, np.ndarray] func:~cadjoint.fem.quality.aspect_ratios);
dict[str, np.ndarray] {"radius_ratio": (C,), "aspect_ratio": (C,)} for tet
dict[str, np.ndarray] meshes (see :func:~cadjoint.fem.quality.tet_radius_ratios /
dict[str, np.ndarray] func:~cadjoint.fem.quality.tet_aspect_ratios; TET10 metrics
dict[str, np.ndarray] are those of the straight-sided corner tets).