crashmetrics.mesh¶
mesh
¶
Read the mesh of an LS-DYNA keyword file: nodes, elements and parts.
read_mesh reads *NODE, *ELEMENT_SHELL, *ELEMENT_SOLID,
*ELEMENT_BEAM (and their _TITLE or option forms), and the
titles of *PART cards, in fixed, long (+ or %) and comma
formats. The result, a Mesh, gives the node coordinates of any parts,
for geometry checks such as bonnet clearance
(crashmetrics.pedestrian.clearance). write_mesh writes nodes and
shell elements in the keyword format.
Includes (*INCLUDE) are not followed: read each file and combine the
meshes with Mesh.merge, or give the file that holds the parts.
Mesh
dataclass
¶
Mesh(
node_ids: NDArray[int64],
coordinates: FloatArray,
elements: dict[
str, dict[int, tuple[int, tuple[int, ...]]]
] = dict(),
part_names: dict[int, str] = dict(),
source: str = "",
)
Nodes, elements and parts of a keyword file (model units).
elements
class-attribute
instance-attribute
¶
Element type -> element ID -> (part ID, node IDs).
part_nodes
¶
IDs of the nodes of a part's elements, sorted.
points
¶
Coordinates (n, 3) of the nodes of one or several parts.
coordinates_of
¶
Coordinates (n, 3) of the given nodes.
find_parts
¶
Part IDs whose title matches a pattern (*, ?; case
ignored).
read_mesh
¶
read_mesh(
path: str | Path, *, parts: Iterable[int] | None = None
) -> Mesh
Read nodes, elements and part titles of a keyword file.
parts keeps only the elements of those parts (and all nodes).
write_mesh
¶
write_mesh(
path: str | Path,
node_ids: Sequence[int] | NDArray[int64],
coordinates: FloatArray,
shells: Mapping[int, tuple[int, Sequence[int]]],
part_names: Mapping[int, str],
*,
title: str = "",
) -> Path
Write *NODE, *PART (title only, no section or material) and
*ELEMENT_SHELL in fixed format.