Skip to main content

Read nodes and elements from LS-DYNA decks.

Project description

LS-DYNA Mesh Reader

This library can be used to read in LS-DYNA meshes stored within keyword (*.k, *.key, *.dyn) files, also known as keyword format "input decks". Full documentation for this repository can be found at lsdyna-mesh-reader Documentation.

Many of these example files were obtained from the excellent documentation at LS-DYNA Examples.

Motivation

Despite its popularity, there doesn't appear to be a reader for LS-DYNA keyword files. I need a reader for a closed source project and hope that this helps someone else who also wishes to read in these files. It borrows from mapdl-archive as MAPDL also follows many of the same FORTRAN conventions when writing out FEMs.

Installation

Install the fully featured reader with visualization with:

pip install lsdyna-mesh-reader[pyvista]

If you only need the node and element arrays and not any VTK features (e.g. plotting or UnstructuredGrid representation), install the basic library with:

pip install lsdyna-mesh-reader

Examples

Before going through a basic example, let's talk about how these "decks" are organized. Each keyword file contains "keywords" that describe the start of sections of "cards". This terminology dates back to when DYNA3D was developed in 1976 where programs were written on punch cards.

To read in nodes and elements, we have to read in one or more node and element sections, each starting with *NODE or *ELEMENT_SOLID. This library loads in those raw sections as well as parsed sections as a higher level abstraction.

Let's start by loading the Contact Eroding I example deck.

Load the birdball deck.

>>> import lsdyna_mesh_reader
>>> from lsdyna_mesh_reader import examples
>>> deck = lsdyna_mesh_reader.Deck(examples.birdball)
LSDYNA Deck with:
  Node sections:              1
  Element Solid sections:     1
  Element Shell sections:     1

We can now inspect one of the node sections:

>>> node_section = deck.node_sections[0]
>>> node_section
NodeSection containing 1281 nodes

|  NID  |       X       |       Y       |       Z       |   tc   |   rc   |
|-------|---------------|---------------|---------------|--------|--------|
       1 -2.30940104e+00 -2.30940104e+00 -2.30940104e+00        0        0
       2 -2.03960061e+00 -2.03960061e+00 -2.03960061e+00        0        0
       3 -1.76980031e+00 -1.76980031e+00 -1.76980031e+00        0        0
       4 -1.50000000e+00 -1.50000000e+00 -1.50000000e+00        0        0
       5 -2.59364843e+00 -1.59561157e+00 -2.59364843e+00        0        0
       6 -2.22909880e+00 -1.39707434e+00 -2.22909880e+00        0        0
       7 -1.86454940e+00 -1.19853711e+00 -1.86454940e+00        0        0
       8 -1.50000000e+00 -1.00000000e+00 -1.50000000e+00        0        0
       9 -2.76911068e+00 -8.14893484e-01 -2.76911068e+00        0        0
      10 -2.34607387e+00 -7.09928930e-01 -2.34607387e+00        0        0
...

We can directly access the node IDs and arrays of the node section:

Node IDs

>>> node_section.nid
array([   1,    2,    3, ..., 1342, 1343, 1344], dtype=int32)

Node coordinates

>>> node_section.coordinates
array([[ -2.30940104,  -2.30940104,  -2.30940104],
       [ -2.03960061,  -2.03960061,  -2.03960061],
       [ -1.76980031,  -1.76980031,  -1.76980031],
       ...,
       [ -4.        , -10.        ,   0.        ],
       [ -2.        , -10.        ,   0.        ],
       [  0.        , -10.        ,   0.        ]])

The same can be done for both the solid and shell element sections.

>>> deck.element_solid_sections  # or deck.element_shell_sections
[ElementSolidSection containing 816 elements

 |  EID  |  PID  |  N1   |  N2   |  N3   |  N4   |  N5   |  N6   |  N7   |  N8   |
 |-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
        1       1       1       2       6       5      17      18      22      21
        2       1       2       3       7       6      18      19      23      22
        3       1       3       4       8       7      19      20      24      23
        4       1       5       6      10       9      21      22      26      25
        5       1       6       7      11      10      22      23      27      26
        6       1       7       8      12      11      23      24      28      27
        7       1       9      10      14      13      25      26      30      29
        8       1      10      11      15      14      26      27      31      30
        9       1      11      12      16      15      27      28      32      31
       10       1      17      18      22      21      33      34      38      37
 ...]

Element IDs

>>> section = deck.element_solid_sections[0]
>>> section.eid
array([  1,   2,   3, ..., 814, 815, 816], dtype=int32)

Node IDs of the elements

>>>
array([   1,    2,    6, ..., 1256, 1267, 1266], dtype=int32)

The elements are stored as a single contiguous array for efficiency and can be split up via:

>>> import numpy as np
>>> elements = np.split(section.node_ids, section.node_id_offsets[1:-1])
[array([ 1,  2,  6,  5, 17, 18, 22, 21], dtype=int32),
 array([ 2,  3,  7,  6, 18, 19, 23, 22], dtype=int32),
...
]

If you have pyvista installed or installed the library with pip install lsdyna-mesh-reader[pyvista], you can convert the mesh to a single unstructured grid:

>>> grid = deck.to_grid()
>>> grid
UnstructuredGrid (0x70d5d723bc40)
  N Cells:    916
  N Points:   1281
  X Bounds:   -2.000e+01, 2.220e-15
  Y Bounds:   -1.000e+01, 4.000e+00
  Z Bounds:   -2.000e+01, 4.441e-15
  N Arrays:   2

This lets you plot, save, or perform other operations on the mesh via PyVista. For example, you could plot the resulting mesh. Here's a full example using the Yaris Static Suspension System Loading Examplew.

>>> filename = "YarisD_V2g_shock_abs_load_01.k"
>>> deck = Deck(filename)
>>> grid = deck.to_grid()
>>> grid.plot(color="w", smooth_shading=True, show_edges=True)

Yaris Static Suspension Mesh

Caveats and Limitations

As of now, limited testing has been performed on this library and you may find that it fails to load complex or simple keyword decks.

Additionally, this reader only supports the following keywords:

  • *NODE
  • *ELEMENT_SHELL
  • *ELEMENT_SOLID
  • *ELEMENT_TSHELL (note: sections encoded as solid sections)

The VTK UnstructuredGrid contains only the linear element conversion of the underlying LS-DYNA elements, and only supports VTK_QUAD, VTK_TRIANGLE, VTK_TETRA, VTK_WEDGE, and VTK_HEXAHEDRAL.

Issues and Contributing

Feel free to open an Issue in this repository with any features you'd like me to add or bugs you need fixed.

If you'd like to contribute, please see CONTRIBUTING.md.

License

Source and content is under the MIT License, except for the LS-DYNA artifacts, which retain their original license from LS-DYNA and Ansys.

Note that the example files used here were downloaded from LS-DYNA Examples and have the following usage license as noted on the website:

The input files and several class notes are available for download. The
download is free of charge, a login is not required. All examples are
presented with a brief description. You may find an example by checking a
specific class or by using the search functionality of the site.

The content is prepared for educational purposes. Hence, material
properties and other parameters might be non-physic for simplification.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lsdyna-mesh-reader-0.1.1.tar.gz (646.9 kB view details)

Uploaded Source

Built Distributions

lsdyna_mesh_reader-0.1.1-cp312-cp312-win_amd64.whl (714.3 kB view details)

Uploaded CPython 3.12 Windows x86-64

lsdyna_mesh_reader-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (741.3 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (704.7 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_10_14_x86_64.whl (710.3 kB view details)

Uploaded CPython 3.12 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.1-cp311-cp311-win_amd64.whl (716.1 kB view details)

Uploaded CPython 3.11 Windows x86-64

lsdyna_mesh_reader-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (707.4 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_10_14_x86_64.whl (713.0 kB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.1-cp310-cp310-win_amd64.whl (716.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

lsdyna_mesh_reader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl (707.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_10_14_x86_64.whl (713.2 kB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.1-cp39-cp39-win_amd64.whl (716.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

lsdyna_mesh_reader-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (744.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (707.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_10_14_x86_64.whl (713.4 kB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

File details

Details for the file lsdyna-mesh-reader-0.1.1.tar.gz.

File metadata

  • Download URL: lsdyna-mesh-reader-0.1.1.tar.gz
  • Upload date:
  • Size: 646.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for lsdyna-mesh-reader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2b76059092eeee9a200577c8d9b0e4d78415a693f53942511f9a56a238972074
MD5 5d0de72696c0ed82d56f23eb9dba68dc
BLAKE2b-256 b1aac7da938c469c4b821da02806428c970f5f8e284eacb6af5cd9b7cf714b73

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c7f5f32171fe57f6dea34a0d7a9dd98cc223ba6b255119fae635c7da50af4b4
MD5 8da46cd2638c450a7b754e5f64ff1613
BLAKE2b-256 78f92f6fd146af9884457a3a53d4c20ffccca522526a71d806d3d99946c416b5

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c87f1cc2167bba2225ab98f4552692ebca94b43179d45248b757a3505ca3b97
MD5 06b17e1f8d6231fea40389af81d80fea
BLAKE2b-256 c63784942f577fa6ac2ae6f3dfa0a3585a0f5e273f71ae67192173e18aecc3bd

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 828fd948e41ba855d327197958b26dbdb8ce932464327b0868f54f0b9590d273
MD5 e3fc513eba708b872bc8a0e999279374
BLAKE2b-256 b7d19aeac01b35bde68cf0c305db3fb12e4279040f2fbb5c96d092ed0c82aea6

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ace76941514923390f278211fb79fab6c96ea8d12bb3b7d2c310134d60e0e159
MD5 03a96962faea4cb6e6e4eeb728cb1043
BLAKE2b-256 15be7e404354f46bdaecf17e40ac0b5a8b4f66466fdd599d5a6d4d16f8b85e05

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6b18518b14b85f62198182a175e1d58f172c43ee6fd5f83e74c3eb6a34a54975
MD5 754a4f43eb7179bd9906410957e002a8
BLAKE2b-256 ad369ea962f4eac6a145b8d2455e5a67ef78d019c6867ba00f775d82e0c27481

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d961acde554c3842891359098a245238df1dc06fd17bd52e99f86df003a538b0
MD5 e0ac9f56afeed69fafa6db20f31c5865
BLAKE2b-256 89cf63bea3897490dc7d7f933a7b8d8c44b5193deb19c9664f9898f918c623e9

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dfc3bd2d37666f79fe696da1d5d78cf1d21179337a144ddec7fa3f5fd1ca87c8
MD5 a5012a0e372215ddcace9de67d0c8de7
BLAKE2b-256 a187436ceab4b368d1be69727cc39533dc6a8327f8206725f83e52bfd7d468c2

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c1cb4365864ef8b6562ffebee41f7d3d1e1cef71151976b8285955da4057347a
MD5 d41cde4eccb530183772daec9eca5338
BLAKE2b-256 38c7e047e2ebbb830e558cb06c930eb6ba98a7513557e2821c1462caf456be66

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 59c34c52be2b895bdeb5ec1b8ee405a4738fdfabda5026a0aeda4096eb453f85
MD5 ef952a7ca8a4f5ddc38f9c0360ed1b64
BLAKE2b-256 e8576f6b03e49c0a357249e3c0412867c0f4fe1d618290708b2e8e82f24f85e3

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d99e983a6e625fb197e9366828c1e716d7cc9520168747118b125dcad704dba
MD5 65de9fc8df586f3361564b2a5a68902f
BLAKE2b-256 7c40906045087c0ac60c99ec3c7dc8bbdcb5ec8b202626b2598e9e8afd27652f

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 795731f5b8d841426f8ac04ebbaaa869c4d15ac4d972f71c2e8dbf6ed615a947
MD5 ac7b42fa20712ae5f5efa47495d4bf58
BLAKE2b-256 49cb8381475a19f3f714e2dfb6a88d8ca3c5a0bd8e74451e12cc0d8118b180f0

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a47c15273dfb3099f2e9ed8ab7301221ba8d1b0dcd258e7bbda21799fa5d61ed
MD5 f504ac32c244c01cfe33c346d8464466
BLAKE2b-256 b471eb135b1b3d102f654a29efdf8795d01d1048cc3e74a879e01a9a571dc938

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f2ad2326202f06439b8370ebba959325628bc1ee02db1236ec66d99b7a266303
MD5 62021b9f67b6bcd64acecf4e1fd18f32
BLAKE2b-256 0388d18705f48a52bf11657855ff7b2e551da1bf142f1488c482637f1d3e51c3

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33b13181cbc52bafbee58c7d551c1024a658370a5c6639779062a126761bd7d0
MD5 b2bf2edd563eee22934ace8aed68ae3e
BLAKE2b-256 ec97ddb1bb10e0919028d843f2531a25a020419c68f546a646bf932780678a40

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 985fd6f16394b21743bc7ef525ebd8ec68df4e9221db64a0eaba0fc0499de265
MD5 c3cdd4976ceedfafebf28451bc45e58a
BLAKE2b-256 1cf9dc2f522d304014c40d1794c337f8d213faf7985e0767b019b889ea64c8f4

See more details on using hashes here.

File details

Details for the file lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.1-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 43f255b3e77d335d1d17023fcffba44069e1e63ac23d45677a6e1933ca75b1eb
MD5 ad49c818c5a06b0fb62de501a0a4d23b
BLAKE2b-256 13faf2046fedfe8c058a54df30e135064d0733c51be36159bf60f7cb45e670c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page