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 meshes defines one LS-DYNA *PART.

  • A HybridMesh may be referenced by multiple part entries using blocks to 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.extra or part.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 : dict

  • materials : dict

  • sections : dict

  • model : 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 : Mesh or HybridMesh instance

  • sets :

    • "all" → export all node and element sets (default)

    • None or [] → export no sets

    • list[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 for HybridMesh objects

    • None or omitted → export all HybridMesh blocks

    • "all" → export all HybridMesh blocks

    • list[int] → export only the specified block indices

    For regular Mesh objects, blocks is ignored.

    HelloTriangle type

    LS-DYNA type

    line2

    BEAM

    tri3

    SHELL

    quad4

    SHELL

    tet4

    SOLID

    hex8

    SOLID

    wedge6

    SOLID

  • material : material name (str)

  • section : section key (str) pointing to sections dictionary

  • extra : 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, or SOLID.

  • 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 HybridMesh may 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_LIST or *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 0 is written as shell_part

  • block 1 is written as solid_part

  • the nodes of hybrid_mesh are written only once

  • both parts reference the same global node numbering

Materials and sections#

Materials#

Material dictionary fields:

  • type : currently only elastic is supported

  • parameters : dict of material properties:

    • E : Young’s modulus

    • nu : Poisson’s ratio

    • rho : density (optional)

  • extra : optional raw LS-DYNA snippet for custom materials

Sections#

Section dictionary fields:

  • type : solid, shell, or beam

  • thickness : required for shell sections

  • elform : optional element formulation (shells default = 2, solid default = 1)

  • shrf : optional shell-specific parameter

  • nip : optional number of integration points for shells

  • extra : optional raw LS-DYNA snippet

Boundary conditions#

Supported BC types:

  • fixed

  • displacement

  • velocity

  • acceleration

BC dictionary fields:

  • target : dict with:

    • mesh : mesh name

    • set : 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] pairs

  • extra : 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")