LS-DYNA Exporter#
Overview#
HelloTriangle provides functionality to export meshes and complete simulation setups
to LS-DYNA .k files. Supported features include:
Single or multiple meshes (
Mesh/HybridMesh)Node and element sets
Materials and sections (per-part)
Curves / amplitudes
Boundary conditions (BCs), including fixed and prescribed motion
Raw LS-DYNA snippet injection at different levels
Note
Each entry in
meshesdefines one LS-DYNA*PART.A
HybridMeshmay be referenced by multiple part entries usingblocksto assign different element blocks to different parts.Nodes are written only once for each unique mesh object and can therefore be shared by multiple parts referring to the same mesh.
Node and element numbering is global and continuous.
Advanced LS-DYNA features (e.g., contacts, termination control) must be provided via raw snippets in
model.extraorpart.extra.
Simulation setup dictionary#
The high-level user API is:
save_simulation(simulation_setup, "myinputfile.k")
The simulation_setup dictionary may contain the following top-level keys:
meshes: dictmaterials: dictsections: dictmodel: dict (optional)amplitudes: dict (optional)BCs: dict (optional)
Meshes and parts#
Each entry in meshes defines one LS-DYNA part.
A regular Mesh contains a single element type and contributes all of its
elements to its part. The optional blocks entry is ignored for regular
Mesh objects.
A HybridMesh contains multiple element connectivity blocks. A
HybridMesh may be referenced by multiple part entries, with each entry
selecting which blocks belong to that part.
Per-part configuration fields:
mesh:MeshorHybridMeshinstancesets:"all"→ export all node and element sets (default)Noneor[]→ export no setslist[str]→ export only the named sets
eltype:LS-DYNA element type, e.g.,
SHELL,SOLID,BEAM.Defaults are automatically mapped from HelloTriangle element types:
blocks: optional block selection forHybridMeshobjectsNoneor omitted → export all HybridMesh blocks"all"→ export all HybridMesh blockslist[int]→ export only the specified block indices
For regular
Meshobjects,blocksis ignored.HelloTriangle type
LS-DYNA type
line2BEAMtri3SHELLquad4SHELLtet4SOLIDhex8SOLIDwedge6SOLIDmaterial: material name (str)section: section key (str) pointing tosectionsdictionaryextra: optional raw LS-DYNA snippet appended to the part
Note
A single LS-DYNA part must contain only one LS-DYNA element category:
BEAM,SHELL, orSOLID.For a
HybridMesh, all selected blocks in one part must therefore resolve to the same LS-DYNA element category.A HybridMesh block may be assigned to only one part.
The same
HybridMeshmay be reused by multiple parts as long as the selected block sets do not overlap.Nodes are shared between parts referring to the same mesh object.
Node and element sets are assigned integer IDs and written as
*SET_NODE_LISTor*SET_SHELL/*SET_SOLID.Node IDs and element IDs are continuous across parts.
Example: splitting a HybridMesh into parts#
A single HybridMesh can be split into multiple LS-DYNA parts:
simulation_setup = {
"meshes": {
"shell_part": {
"mesh": hybrid_mesh,
"blocks": [0],
"material": "STEEL",
"section": "shell_sec",
},
"solid_part": {
"mesh": hybrid_mesh,
"blocks": [1],
"material": "ALUMINUM",
"section": "solid_sec",
},
},
...
}
In this example:
block
0is written asshell_partblock
1is written assolid_partthe nodes of
hybrid_meshare written only onceboth parts reference the same global node numbering
Materials and sections#
Materials#
Material dictionary fields:
type: currently onlyelasticis supportedparameters: dict of material properties:E: Young’s modulusnu: Poisson’s ratiorho: density (optional)
extra: optional raw LS-DYNA snippet for custom materials
Sections#
Section dictionary fields:
type:solid,shell, orbeamthickness: required for shell sectionselform: optional element formulation (shells default = 2, solid default = 1)shrf: optional shell-specific parameternip: optional number of integration points for shellsextra: optional raw LS-DYNA snippet
Boundary conditions#
Supported BC types:
fixeddisplacementvelocityacceleration
BC dictionary fields:
target: dict with:mesh: mesh nameset: node set name
dofs: list of DOF indices (0-based, default all [0..5])0 = X, 1 = Y, 2 = Z, 3 = Rx, 4 = Ry, 5 = Rz
amplitude: optional amplitude name (required for displacement, velocity, acceleration)type: BC type
Note
Fixed BCs and prescribed motions are written globally.
LS-DYNA amplitudes define time-dependent behavior for displacement, velocity, or acceleration BCs.
Amplitudes (curves)#
Tabular amplitudes are supported.
Amplitude dictionary fields:
values: list of[time, value]pairsextra: optional raw LS-DYNA snippet
LS-DYNA amplitudes are written as *DEFINE_CURVE blocks.
Example: Cantilever beam with contact#
import numpy as np
cube = shapes.rectangle(div=[10, 4], dim=[10, 1], eltype="quad4")
fixed_nodes = np.where(np.isclose(cube.coords[:, 0], 0.0))[0]
cube.add_set(fixed_nodes, name="fixed")
sphere = shapes.sphere(long_div=18, lat_div=9).translate([9.0, 0.5, 1.5])
sphere_all = np.arange(len(sphere.coords))
sphere.add_set(sphere_all, name="Nall")
extra_settings = """*CONTACT_AUTOMATIC_SURFACE_TO_SURFACE
$# ssid msid sstyp mstyp
1 2 3 3
$# fs fd
0.2 0.1
$# sfsa sfsb
1.0 1.0
*CONTROL_TERMINATION
$# endtim endcyc dtmin endeng endmas
2.0 0 0.0 0.0 0.0
"""
simulation_setup = {
"meshes": {
"beam": {
"mesh": cube,
"sets": ["fixed"],
"material": "STEEL",
"eltype": "SHELL",
"section": "shell_sec",
},
"sphere": {
"mesh": sphere,
"sets": ["Nall"],
"material": "STEEL",
"eltype": "SHELL",
"section": "shell_sec",
},
},
"materials": {
"STEEL": {
"type": "elastic",
"parameters": {"E": 210e9, "nu": 0.3, "rho": 7800},
},
},
"sections": {
"shell_sec": {
"type": "shell",
"thickness": 0.4,
"elform": 2,
}
},
"amplitudes": {
"amp1": {
"values": [[0.0, 0.0], [2.0, -8.0]],
},
},
"BCs": {
"bc_fixed": {
"type": "fixed",
"target": {"mesh": "beam", "set": "fixed"},
},
"bc_disp": {
"type": "displacement",
"target": {"mesh": "sphere", "set": "Nall"},
"dofs": [2],
"amplitude": "amp1",
},
},
"model": {"extra": extra_settings},
}
save_simulation(simulation_setup, "cantilever_contact.k")