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.3.tar.gz (648.0 kB view details)

Uploaded Source

Built Distributions

lsdyna_mesh_reader-0.1.3-cp312-cp312-win_amd64.whl (719.6 kB view details)

Uploaded CPython 3.12 Windows x86-64

lsdyna_mesh_reader-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (746.6 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (710.2 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp312-cp312-macosx_10_14_x86_64.whl (716.2 kB view details)

Uploaded CPython 3.12 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp311-cp311-win_amd64.whl (721.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

lsdyna_mesh_reader-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (749.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (713.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp311-cp311-macosx_10_14_x86_64.whl (719.0 kB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp310-cp310-win_amd64.whl (721.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

lsdyna_mesh_reader-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (749.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (713.5 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp310-cp310-macosx_10_14_x86_64.whl (719.2 kB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp39-cp39-win_amd64.whl (721.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

lsdyna_mesh_reader-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (750.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lsdyna_mesh_reader-0.1.3-cp39-cp39-macosx_11_0_arm64.whl (713.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp39-cp39-macosx_10_14_x86_64.whl (719.5 kB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

File details

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

File metadata

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

File hashes

Hashes for lsdyna-mesh-reader-0.1.3.tar.gz
Algorithm Hash digest
SHA256 22ca1ee34d8b64e0f0444a213512dd771c0bed3062cc36d5d02f8be4192c11af
MD5 7ce7a3313a9dfc2f16b0210c984e63b0
BLAKE2b-256 8a956aa9792ee3a225030db0d8a48915b570dddf53ecdd84b9a2cfa2d7243f80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bdc0ca398b305f4f120098b67a004952faf2eef95fc4b10ff9ed453fa412f422
MD5 1a5b31eaa79010f24de74934cbd609e0
BLAKE2b-256 8b67e52f1eaf15cce15b85a9785877583f60b077f77b4b1a67cc317cb4d8a319

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d17a2d473eff61ef173f8d09ae88304e5b2c60040f4a4a0404544b0e0759ea9a
MD5 680a98fd4a736f0e07804946e998f9d0
BLAKE2b-256 ec18d4a9e3e55945acd52a0f92623edea08a3d2d9d04e0bd30b06106fdc51194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcec31c0a8e07461c2b2947493d976d51338d692ff0663a03a25cd81747f247d
MD5 1314ace8192f044653bf99ce503c722c
BLAKE2b-256 9c4d583277d451df3e7a53cfd8cef91939c4eeb68fbf55ededec0abce479fca0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ee86702cd31318c5edbefd94ebf698e2790264acd9b2dd021a4d480e7d8d2711
MD5 bf17a689d62c3c5ad004645415c6404c
BLAKE2b-256 1b198f493a01f4198ad24cf71b4c4538eba83276334f32a61b012af2a10dbfee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7861259e791a98ad5d4b688a6c2ab28e9bfb8eced147e97008194d0913f2ff56
MD5 e5a017671980e2fefb193798608a5916
BLAKE2b-256 ac2f01131d7b5d50ea37eb141cb80711042ab3eb1d57baa9c3a15f15dc9e7430

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a97aec61e82fb2517847fa33aa3e4986600eda4de947c5bd3561bb6fc550f75
MD5 88a3204965f8c436e4c900eda6962cec
BLAKE2b-256 a2d8b4061ecea5d5a7afaa4d9d2a8386080b4f4b97ff6a6e2ea44edb58646f58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08d2fb2ac4c3e3b3dcf5b2fc60c8b06d8176b65412f18500f3af46564371a717
MD5 8858a4f273a5e42954d6452527e93712
BLAKE2b-256 9ca075f4b34e88c7fa68abac9b9b7331fe4fea2c54c76d9da5fcefdad714fd51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 be3564ada92d1dfe204672db3ae3eef0c2b0b8e2c2417faa7d03135af1f3917d
MD5 285a4e3608d0797dab61bcff3ce634db
BLAKE2b-256 747bf62a107d42ff11a500ff60909c46fea64eb96a68912829c0baea93197c7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cfbf1d604aa08a9439eeee28bd6f620a6ccb0835329be16880df46f3ac34a78d
MD5 36c7382d8af04311bb5d87210bab0563
BLAKE2b-256 65644c8f522ac0f349cb42bf6c23036ddaaba528a9ff587bf45471ff13ff095a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d2e3a45b088982eb846ab2a0998803185394dbe4e02c5ede66c8c64363fb7f6
MD5 c05425c1b33905824f65cd64787fad35
BLAKE2b-256 edc5bb4abaa2869e9efe041af0029f6f69658cdc4d0e78442ffe7b13cfa4ee95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 704e80fc3febf4eb46753b6f89f5d481c329f989f9cdca2f4e038825d07791d2
MD5 82566b2baa1e2909862becf89e526d2d
BLAKE2b-256 716a251b730aaadfafa3796e0d98b639bc69d6982c6bf85a7e8eaaf77a7a5bd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 48d3fcff0df0ac7e42cbdcf953253f022925ea46e9e7f553420f26cff46628d2
MD5 0a1c94f08e99b3bf54302f99385d9c62
BLAKE2b-256 193eb4a301fd50f7fa7d811898924907cf3ad02198854d12d1579fd632931819

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 de5869f14e2fff0fc15fc798ef229593f367c91a266636a482dbf6ec8ad5f0ef
MD5 fae1fa7d276fdcd84ca9bf0857ff7e53
BLAKE2b-256 92e35c1b699cad18bb5f82e521f115f6b8fa66f675e9de47b058ea7da699d47c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 216668a034fa179653bd54161732020540869f34d8273fd47c1f0bfd9105f10b
MD5 3370d67027e6ddceb03c1279f8301253
BLAKE2b-256 70a21364198c6ffd41fef8cdb21b860ac9cfc4a47d20146006a57c61548bd4aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54274592936130a03238421a2c081b1d60181633eec467274c2cf7643d71f039
MD5 e97fed777e993bfde69246cb78685c9c
BLAKE2b-256 3284c1b84aaea5712bcbb28432b46ca8f2393ed9ce7d16661bce9947fc6e4412

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lsdyna_mesh_reader-0.1.3-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 d6e76db30d8b14cebfef8f6836781a88d4053d3be4da33dbe5fa2235de7592bf
MD5 85e33ea922193f8f6ae33475d849779e
BLAKE2b-256 b9aec40c1bf900830d7aaecd4db52fec8f6e716aa3945c8c84ecce82872007fa

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