lsdyna-mesh-reader 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lsdyna-mesh-reader-0.1.0/CMakeLists.txt +31 -0
- lsdyna-mesh-reader-0.1.0/LICENSE +21 -0
- lsdyna-mesh-reader-0.1.0/PKG-INFO +239 -0
- lsdyna-mesh-reader-0.1.0/README.md +212 -0
- lsdyna-mesh-reader-0.1.0/docs/source/_templates/autosummary/base.rst +5 -0
- lsdyna-mesh-reader-0.1.0/docs/source/_templates/autosummary/class.rst +38 -0
- lsdyna-mesh-reader-0.1.0/docs/source/_templates/autosummary/module.rst +65 -0
- lsdyna-mesh-reader-0.1.0/docs/source/_templates/custom-class-template.rst +34 -0
- lsdyna-mesh-reader-0.1.0/docs/source/_templates/custom-module-template.rst +66 -0
- lsdyna-mesh-reader-0.1.0/docs/source/api.rst +13 -0
- lsdyna-mesh-reader-0.1.0/docs/source/conf.py +203 -0
- lsdyna-mesh-reader-0.1.0/docs/source/index.md +17 -0
- lsdyna-mesh-reader-0.1.0/pyproject.toml +77 -0
- lsdyna-mesh-reader-0.1.0/src/array_support.h +110 -0
- lsdyna-mesh-reader-0.1.0/src/deck.cpp +902 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/__init__.py +15 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/_deck.pyi +53 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/deck.py +244 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/EXP_SC_JOINT_SCREW.key +9169 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/__init__.py +37 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/bird.k +16693 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/birdball.k +3567 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/bracket.k +4020 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/examples/wheel.k +23482 -0
- lsdyna-mesh-reader-0.1.0/src/lsdyna_mesh_reader/py.typed +1 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15...3.26)
|
|
2
|
+
|
|
3
|
+
project(nanobind_project LANGUAGES CXX)
|
|
4
|
+
# find_package(OpenMP REQUIRED)
|
|
5
|
+
|
|
6
|
+
# Try to import all Python components potentially needed by nanobind
|
|
7
|
+
find_package(Python 3.8
|
|
8
|
+
REQUIRED COMPONENTS Interpreter Development.Module
|
|
9
|
+
OPTIONAL_COMPONENTS Development.SABIModule)
|
|
10
|
+
|
|
11
|
+
# Import nanobind through CMake's find_package mechanism
|
|
12
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
13
|
+
|
|
14
|
+
nanobind_add_module(_deck STABLE_ABI NB_STATIC src/deck.cpp)
|
|
15
|
+
|
|
16
|
+
# Compiler-specific options
|
|
17
|
+
if(MSVC)
|
|
18
|
+
# Use MSVC optimization levels and OpenMP setup
|
|
19
|
+
target_compile_options(_deck PRIVATE /O2 /std:c++17)
|
|
20
|
+
else()
|
|
21
|
+
# Assuming GCC or Clang
|
|
22
|
+
target_compile_options(_deck PRIVATE -O3)
|
|
23
|
+
endif()
|
|
24
|
+
|
|
25
|
+
# Example debugging
|
|
26
|
+
# set solib-search-path /home/user/python/.venv311/lib/python3.11/site-packages/lsdyna_mesh_reader/
|
|
27
|
+
# set breakpoint with b _deck.cpp:<LINE_NUMBER>
|
|
28
|
+
# target_compile_options(_deck PRIVATE -g -O0)
|
|
29
|
+
|
|
30
|
+
# Install directive for scikit-build-core
|
|
31
|
+
install(TARGETS _deck LIBRARY DESTINATION lsdyna_mesh_reader)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Alex Kaszynski. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: lsdyna-mesh-reader
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Read nodes and elements from LS-DYNA decks.
|
|
5
|
+
Author-Email: Alex Kaszynski <akascap@gmail.com>
|
|
6
|
+
Classifier: Development Status :: 4 - Beta
|
|
7
|
+
Classifier: Intended Audience :: Science/Research
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
+
Classifier: Operating System :: POSIX
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Project-URL: Repository, https://github.com/akaszynski/lsdyna-mesh-reader
|
|
18
|
+
Requires-Python: >=3.9
|
|
19
|
+
Requires-Dist: numpy>=1.22.4
|
|
20
|
+
Requires-Dist: pydata-sphinx-theme; extra == "docs"
|
|
21
|
+
Requires-Dist: numpydoc; extra == "docs"
|
|
22
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
23
|
+
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
24
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
25
|
+
Provides-Extra: docs
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# LS-DYNA Mesh Reader
|
|
29
|
+
|
|
30
|
+
This library can be used to read in LS-DYNA meshes stored within keyword
|
|
31
|
+
(`*.k`, `*.key`, `*.dyn`) files, also known as keyword format "input
|
|
32
|
+
decks".
|
|
33
|
+
|
|
34
|
+
Many of these example files were obtained from the excellent documentation at
|
|
35
|
+
[LS-DYNA Examples](https://www.dynaexamples.com/).
|
|
36
|
+
|
|
37
|
+
## Motivation
|
|
38
|
+
|
|
39
|
+
Despite its popularity, there doesn't appear to be a reader for LS-DYNA keyword
|
|
40
|
+
files. I need a reader for a closed source project and hope that this helps
|
|
41
|
+
someone else who also wishes to read in these files. It borrows from
|
|
42
|
+
[mapdl-archive](https://github.com/akaszynski/mapdl-archive) as MAPDL also
|
|
43
|
+
follows many of the same FORTRAN conventions when writing out FEMs.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Install the fully featured reader with visualization with:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install lsdyna-mesh-reader[pyvista]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If you only need the node and element arrays and not any VTK features
|
|
54
|
+
(e.g. plotting or
|
|
55
|
+
[UnstructuredGrid](https://docs.pyvista.org/api/core/_autosummary/pyvista.unstructuredgrid)
|
|
56
|
+
representation), install the basic library with:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install lsdyna-mesh-reader
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Examples
|
|
63
|
+
|
|
64
|
+
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](https://en.wikipedia.org/wiki/Punched_card).
|
|
65
|
+
|
|
66
|
+
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.
|
|
67
|
+
|
|
68
|
+
Let's start by loading the [Contact Eroding
|
|
69
|
+
I](https://www.dynaexamples.com/introduction/intro-by-a.-tabiei/contact/contact-eroding-i)
|
|
70
|
+
example deck.
|
|
71
|
+
|
|
72
|
+
```py
|
|
73
|
+
|
|
74
|
+
Load the birdball deck.
|
|
75
|
+
|
|
76
|
+
>>> import lsdyna_mesh_reader
|
|
77
|
+
>>> from lsdyna_mesh_reader import examples
|
|
78
|
+
>>> deck = lsdyna_mesh_reader.Deck(examples.birdball)
|
|
79
|
+
LSDYNA Deck with:
|
|
80
|
+
Node sections: 1
|
|
81
|
+
Element Solid sections: 1
|
|
82
|
+
Element Shell sections: 1
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
We can now inspect one of the node sections:
|
|
86
|
+
|
|
87
|
+
```py
|
|
88
|
+
>>> node_section = deck.node_sections[0]
|
|
89
|
+
>>> node_section
|
|
90
|
+
NodeSection containing 1281 nodes
|
|
91
|
+
|
|
92
|
+
| NID | X | Y | Z | tc | rc |
|
|
93
|
+
|-------|---------------|---------------|---------------|--------|--------|
|
|
94
|
+
1 -2.30940104e+00 -2.30940104e+00 -2.30940104e+00 0 0
|
|
95
|
+
2 -2.03960061e+00 -2.03960061e+00 -2.03960061e+00 0 0
|
|
96
|
+
3 -1.76980031e+00 -1.76980031e+00 -1.76980031e+00 0 0
|
|
97
|
+
4 -1.50000000e+00 -1.50000000e+00 -1.50000000e+00 0 0
|
|
98
|
+
5 -2.59364843e+00 -1.59561157e+00 -2.59364843e+00 0 0
|
|
99
|
+
6 -2.22909880e+00 -1.39707434e+00 -2.22909880e+00 0 0
|
|
100
|
+
7 -1.86454940e+00 -1.19853711e+00 -1.86454940e+00 0 0
|
|
101
|
+
8 -1.50000000e+00 -1.00000000e+00 -1.50000000e+00 0 0
|
|
102
|
+
9 -2.76911068e+00 -8.14893484e-01 -2.76911068e+00 0 0
|
|
103
|
+
10 -2.34607387e+00 -7.09928930e-01 -2.34607387e+00 0 0
|
|
104
|
+
...
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
We can directly access the node IDs and arrays of the node section:
|
|
109
|
+
|
|
110
|
+
```py
|
|
111
|
+
Node IDs
|
|
112
|
+
|
|
113
|
+
>>> node_section.nid
|
|
114
|
+
array([ 1, 2, 3, ..., 1342, 1343, 1344], dtype=int32)
|
|
115
|
+
|
|
116
|
+
Node coordinates
|
|
117
|
+
|
|
118
|
+
>>> node_section.coordinates
|
|
119
|
+
array([[ -2.30940104, -2.30940104, -2.30940104],
|
|
120
|
+
[ -2.03960061, -2.03960061, -2.03960061],
|
|
121
|
+
[ -1.76980031, -1.76980031, -1.76980031],
|
|
122
|
+
...,
|
|
123
|
+
[ -4. , -10. , 0. ],
|
|
124
|
+
[ -2. , -10. , 0. ],
|
|
125
|
+
[ 0. , -10. , 0. ]])
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The same can be done for both the solid and shell element sections.
|
|
129
|
+
|
|
130
|
+
```py
|
|
131
|
+
>>> deck.element_solid_sections # or deck.element_shell_sections
|
|
132
|
+
[ElementSolidSection containing 816 elements
|
|
133
|
+
|
|
134
|
+
| EID | PID | N1 | N2 | N3 | N4 | N5 | N6 | N7 | N8 |
|
|
135
|
+
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
|
136
|
+
1 1 1 2 6 5 17 18 22 21
|
|
137
|
+
2 1 2 3 7 6 18 19 23 22
|
|
138
|
+
3 1 3 4 8 7 19 20 24 23
|
|
139
|
+
4 1 5 6 10 9 21 22 26 25
|
|
140
|
+
5 1 6 7 11 10 22 23 27 26
|
|
141
|
+
6 1 7 8 12 11 23 24 28 27
|
|
142
|
+
7 1 9 10 14 13 25 26 30 29
|
|
143
|
+
8 1 10 11 15 14 26 27 31 30
|
|
144
|
+
9 1 11 12 16 15 27 28 32 31
|
|
145
|
+
10 1 17 18 22 21 33 34 38 37
|
|
146
|
+
...]
|
|
147
|
+
|
|
148
|
+
Element IDs
|
|
149
|
+
|
|
150
|
+
>>> section = deck.element_solid_sections[0]
|
|
151
|
+
>>> section.eid
|
|
152
|
+
array([ 1, 2, 3, ..., 814, 815, 816], dtype=int32)
|
|
153
|
+
|
|
154
|
+
Node IDs of the elements
|
|
155
|
+
|
|
156
|
+
>>>
|
|
157
|
+
array([ 1, 2, 6, ..., 1256, 1267, 1266], dtype=int32)
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The elements are stored as a single contiguous array for efficiency and can be
|
|
162
|
+
split up via:
|
|
163
|
+
|
|
164
|
+
```py
|
|
165
|
+
>>> import numpy as np
|
|
166
|
+
>>> elements = np.split(section.node_ids, section.node_id_offsets[1:-1])
|
|
167
|
+
[array([ 1, 2, 6, 5, 17, 18, 22, 21], dtype=int32),
|
|
168
|
+
array([ 2, 3, 7, 6, 18, 19, 23, 22], dtype=int32),
|
|
169
|
+
...
|
|
170
|
+
]
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
If you have `pyvista` installed or installed the library with `pip install
|
|
174
|
+
lsdyna-mesh-reader[pyvista]`, you can convert the mesh to a single unstructured
|
|
175
|
+
grid:
|
|
176
|
+
|
|
177
|
+
```py
|
|
178
|
+
>>> grid = deck.to_grid()
|
|
179
|
+
>>> grid
|
|
180
|
+
UnstructuredGrid (0x70d5d723bc40)
|
|
181
|
+
N Cells: 916
|
|
182
|
+
N Points: 1281
|
|
183
|
+
X Bounds: -2.000e+01, 2.220e-15
|
|
184
|
+
Y Bounds: -1.000e+01, 4.000e+00
|
|
185
|
+
Z Bounds: -2.000e+01, 4.441e-15
|
|
186
|
+
N Arrays: 2
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
This lets you plot, save, or perform other operations on the mesh via
|
|
190
|
+
PyVista. For example, you could plot the resulting mesh. Here's a full example using the [Yaris Static Suspension System Loading Examplew](https://www.dynaexamples.com/implicit/yaris-static-suspension-system-loading).
|
|
191
|
+
|
|
192
|
+
```py
|
|
193
|
+
>>> filename = "YarisD_V2g_shock_abs_load_01.k"
|
|
194
|
+
>>> deck = Deck(filename)
|
|
195
|
+
>>> grid = deck.to_grid()
|
|
196
|
+
>>> grid.plot(color="w", smooth_shading=True, show_edges=True)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+

|
|
200
|
+
|
|
201
|
+
### Caveats and Limitations
|
|
202
|
+
|
|
203
|
+
As of now, limited testing has been performed on this library and you may find
|
|
204
|
+
that it fails to load complex or simple keyword decks.
|
|
205
|
+
|
|
206
|
+
Additionally, this reader only supports the following keywords:
|
|
207
|
+
|
|
208
|
+
* `*NODE`
|
|
209
|
+
* `*ELEMENT_SHELL`
|
|
210
|
+
* `*ELEMENT_SOLID`
|
|
211
|
+
|
|
212
|
+
The VTK UnstructuredGrid contains only the linear element conversion of the
|
|
213
|
+
underlying LS-DYNA elements, and only supports `VTK_QUAD`, `VTK_TRIANGLE`,
|
|
214
|
+
`VTK_TETRA`, `VTK_WEDGE`, and `VTK_HEXAHEDRAL`.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
## Issues and Contributing
|
|
218
|
+
|
|
219
|
+
Feel free to open an [Issue](https://github.com/akaszynski/lsdyna-mesh-reader/issues) in this repository with any features you'd like me to add or bugs you need fixed.
|
|
220
|
+
|
|
221
|
+
If you'd like to contribute, please see [CONTRIBUTING.md](https://github.com/akaszynski/lsdyna-mesh-reader/blob/main/CONTRIBUTING.md).
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
Source and content is under the MIT License, except for the LS-DYNA artifacts,
|
|
227
|
+
which retain their original license from LS-DYNA and Ansys.
|
|
228
|
+
|
|
229
|
+
Note that the example files used here were downloaded from [LS-DYNA
|
|
230
|
+
Examples](https://www.dynaexamples.com/) and have the following usage license
|
|
231
|
+
as noted on the website:
|
|
232
|
+
|
|
233
|
+
The input files and several class notes are available for download. The
|
|
234
|
+
download is free of charge, a login is not required. All examples are
|
|
235
|
+
presented with a brief description. You may find an example by checking a
|
|
236
|
+
specific class or by using the search functionality of the site.
|
|
237
|
+
|
|
238
|
+
The content is prepared for educational purposes. Hence, material
|
|
239
|
+
properties and other parameters might be non-physic for simplification.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# LS-DYNA Mesh Reader
|
|
2
|
+
|
|
3
|
+
This library can be used to read in LS-DYNA meshes stored within keyword
|
|
4
|
+
(`*.k`, `*.key`, `*.dyn`) files, also known as keyword format "input
|
|
5
|
+
decks".
|
|
6
|
+
|
|
7
|
+
Many of these example files were obtained from the excellent documentation at
|
|
8
|
+
[LS-DYNA Examples](https://www.dynaexamples.com/).
|
|
9
|
+
|
|
10
|
+
## Motivation
|
|
11
|
+
|
|
12
|
+
Despite its popularity, there doesn't appear to be a reader for LS-DYNA keyword
|
|
13
|
+
files. I need a reader for a closed source project and hope that this helps
|
|
14
|
+
someone else who also wishes to read in these files. It borrows from
|
|
15
|
+
[mapdl-archive](https://github.com/akaszynski/mapdl-archive) as MAPDL also
|
|
16
|
+
follows many of the same FORTRAN conventions when writing out FEMs.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
Install the fully featured reader with visualization with:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install lsdyna-mesh-reader[pyvista]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If you only need the node and element arrays and not any VTK features
|
|
27
|
+
(e.g. plotting or
|
|
28
|
+
[UnstructuredGrid](https://docs.pyvista.org/api/core/_autosummary/pyvista.unstructuredgrid)
|
|
29
|
+
representation), install the basic library with:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install lsdyna-mesh-reader
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Examples
|
|
36
|
+
|
|
37
|
+
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](https://en.wikipedia.org/wiki/Punched_card).
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
Let's start by loading the [Contact Eroding
|
|
42
|
+
I](https://www.dynaexamples.com/introduction/intro-by-a.-tabiei/contact/contact-eroding-i)
|
|
43
|
+
example deck.
|
|
44
|
+
|
|
45
|
+
```py
|
|
46
|
+
|
|
47
|
+
Load the birdball deck.
|
|
48
|
+
|
|
49
|
+
>>> import lsdyna_mesh_reader
|
|
50
|
+
>>> from lsdyna_mesh_reader import examples
|
|
51
|
+
>>> deck = lsdyna_mesh_reader.Deck(examples.birdball)
|
|
52
|
+
LSDYNA Deck with:
|
|
53
|
+
Node sections: 1
|
|
54
|
+
Element Solid sections: 1
|
|
55
|
+
Element Shell sections: 1
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
We can now inspect one of the node sections:
|
|
59
|
+
|
|
60
|
+
```py
|
|
61
|
+
>>> node_section = deck.node_sections[0]
|
|
62
|
+
>>> node_section
|
|
63
|
+
NodeSection containing 1281 nodes
|
|
64
|
+
|
|
65
|
+
| NID | X | Y | Z | tc | rc |
|
|
66
|
+
|-------|---------------|---------------|---------------|--------|--------|
|
|
67
|
+
1 -2.30940104e+00 -2.30940104e+00 -2.30940104e+00 0 0
|
|
68
|
+
2 -2.03960061e+00 -2.03960061e+00 -2.03960061e+00 0 0
|
|
69
|
+
3 -1.76980031e+00 -1.76980031e+00 -1.76980031e+00 0 0
|
|
70
|
+
4 -1.50000000e+00 -1.50000000e+00 -1.50000000e+00 0 0
|
|
71
|
+
5 -2.59364843e+00 -1.59561157e+00 -2.59364843e+00 0 0
|
|
72
|
+
6 -2.22909880e+00 -1.39707434e+00 -2.22909880e+00 0 0
|
|
73
|
+
7 -1.86454940e+00 -1.19853711e+00 -1.86454940e+00 0 0
|
|
74
|
+
8 -1.50000000e+00 -1.00000000e+00 -1.50000000e+00 0 0
|
|
75
|
+
9 -2.76911068e+00 -8.14893484e-01 -2.76911068e+00 0 0
|
|
76
|
+
10 -2.34607387e+00 -7.09928930e-01 -2.34607387e+00 0 0
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
We can directly access the node IDs and arrays of the node section:
|
|
82
|
+
|
|
83
|
+
```py
|
|
84
|
+
Node IDs
|
|
85
|
+
|
|
86
|
+
>>> node_section.nid
|
|
87
|
+
array([ 1, 2, 3, ..., 1342, 1343, 1344], dtype=int32)
|
|
88
|
+
|
|
89
|
+
Node coordinates
|
|
90
|
+
|
|
91
|
+
>>> node_section.coordinates
|
|
92
|
+
array([[ -2.30940104, -2.30940104, -2.30940104],
|
|
93
|
+
[ -2.03960061, -2.03960061, -2.03960061],
|
|
94
|
+
[ -1.76980031, -1.76980031, -1.76980031],
|
|
95
|
+
...,
|
|
96
|
+
[ -4. , -10. , 0. ],
|
|
97
|
+
[ -2. , -10. , 0. ],
|
|
98
|
+
[ 0. , -10. , 0. ]])
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The same can be done for both the solid and shell element sections.
|
|
102
|
+
|
|
103
|
+
```py
|
|
104
|
+
>>> deck.element_solid_sections # or deck.element_shell_sections
|
|
105
|
+
[ElementSolidSection containing 816 elements
|
|
106
|
+
|
|
107
|
+
| EID | PID | N1 | N2 | N3 | N4 | N5 | N6 | N7 | N8 |
|
|
108
|
+
|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
|
|
109
|
+
1 1 1 2 6 5 17 18 22 21
|
|
110
|
+
2 1 2 3 7 6 18 19 23 22
|
|
111
|
+
3 1 3 4 8 7 19 20 24 23
|
|
112
|
+
4 1 5 6 10 9 21 22 26 25
|
|
113
|
+
5 1 6 7 11 10 22 23 27 26
|
|
114
|
+
6 1 7 8 12 11 23 24 28 27
|
|
115
|
+
7 1 9 10 14 13 25 26 30 29
|
|
116
|
+
8 1 10 11 15 14 26 27 31 30
|
|
117
|
+
9 1 11 12 16 15 27 28 32 31
|
|
118
|
+
10 1 17 18 22 21 33 34 38 37
|
|
119
|
+
...]
|
|
120
|
+
|
|
121
|
+
Element IDs
|
|
122
|
+
|
|
123
|
+
>>> section = deck.element_solid_sections[0]
|
|
124
|
+
>>> section.eid
|
|
125
|
+
array([ 1, 2, 3, ..., 814, 815, 816], dtype=int32)
|
|
126
|
+
|
|
127
|
+
Node IDs of the elements
|
|
128
|
+
|
|
129
|
+
>>>
|
|
130
|
+
array([ 1, 2, 6, ..., 1256, 1267, 1266], dtype=int32)
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The elements are stored as a single contiguous array for efficiency and can be
|
|
135
|
+
split up via:
|
|
136
|
+
|
|
137
|
+
```py
|
|
138
|
+
>>> import numpy as np
|
|
139
|
+
>>> elements = np.split(section.node_ids, section.node_id_offsets[1:-1])
|
|
140
|
+
[array([ 1, 2, 6, 5, 17, 18, 22, 21], dtype=int32),
|
|
141
|
+
array([ 2, 3, 7, 6, 18, 19, 23, 22], dtype=int32),
|
|
142
|
+
...
|
|
143
|
+
]
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If you have `pyvista` installed or installed the library with `pip install
|
|
147
|
+
lsdyna-mesh-reader[pyvista]`, you can convert the mesh to a single unstructured
|
|
148
|
+
grid:
|
|
149
|
+
|
|
150
|
+
```py
|
|
151
|
+
>>> grid = deck.to_grid()
|
|
152
|
+
>>> grid
|
|
153
|
+
UnstructuredGrid (0x70d5d723bc40)
|
|
154
|
+
N Cells: 916
|
|
155
|
+
N Points: 1281
|
|
156
|
+
X Bounds: -2.000e+01, 2.220e-15
|
|
157
|
+
Y Bounds: -1.000e+01, 4.000e+00
|
|
158
|
+
Z Bounds: -2.000e+01, 4.441e-15
|
|
159
|
+
N Arrays: 2
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This lets you plot, save, or perform other operations on the mesh via
|
|
163
|
+
PyVista. For example, you could plot the resulting mesh. Here's a full example using the [Yaris Static Suspension System Loading Examplew](https://www.dynaexamples.com/implicit/yaris-static-suspension-system-loading).
|
|
164
|
+
|
|
165
|
+
```py
|
|
166
|
+
>>> filename = "YarisD_V2g_shock_abs_load_01.k"
|
|
167
|
+
>>> deck = Deck(filename)
|
|
168
|
+
>>> grid = deck.to_grid()
|
|
169
|
+
>>> grid.plot(color="w", smooth_shading=True, show_edges=True)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+

|
|
173
|
+
|
|
174
|
+
### Caveats and Limitations
|
|
175
|
+
|
|
176
|
+
As of now, limited testing has been performed on this library and you may find
|
|
177
|
+
that it fails to load complex or simple keyword decks.
|
|
178
|
+
|
|
179
|
+
Additionally, this reader only supports the following keywords:
|
|
180
|
+
|
|
181
|
+
* `*NODE`
|
|
182
|
+
* `*ELEMENT_SHELL`
|
|
183
|
+
* `*ELEMENT_SOLID`
|
|
184
|
+
|
|
185
|
+
The VTK UnstructuredGrid contains only the linear element conversion of the
|
|
186
|
+
underlying LS-DYNA elements, and only supports `VTK_QUAD`, `VTK_TRIANGLE`,
|
|
187
|
+
`VTK_TETRA`, `VTK_WEDGE`, and `VTK_HEXAHEDRAL`.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
## Issues and Contributing
|
|
191
|
+
|
|
192
|
+
Feel free to open an [Issue](https://github.com/akaszynski/lsdyna-mesh-reader/issues) in this repository with any features you'd like me to add or bugs you need fixed.
|
|
193
|
+
|
|
194
|
+
If you'd like to contribute, please see [CONTRIBUTING.md](https://github.com/akaszynski/lsdyna-mesh-reader/blob/main/CONTRIBUTING.md).
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
Source and content is under the MIT License, except for the LS-DYNA artifacts,
|
|
200
|
+
which retain their original license from LS-DYNA and Ansys.
|
|
201
|
+
|
|
202
|
+
Note that the example files used here were downloaded from [LS-DYNA
|
|
203
|
+
Examples](https://www.dynaexamples.com/) and have the following usage license
|
|
204
|
+
as noted on the website:
|
|
205
|
+
|
|
206
|
+
The input files and several class notes are available for download. The
|
|
207
|
+
download is free of charge, a login is not required. All examples are
|
|
208
|
+
presented with a brief description. You may find an example by checking a
|
|
209
|
+
specific class or by using the search functionality of the site.
|
|
210
|
+
|
|
211
|
+
The content is prepared for educational purposes. Hence, material
|
|
212
|
+
properties and other parameters might be non-physic for simplification.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{{ fullname | escape | underline}}
|
|
2
|
+
|
|
3
|
+
.. currentmodule:: {{ module }}
|
|
4
|
+
|
|
5
|
+
.. autoclass:: {{ objname }}
|
|
6
|
+
|
|
7
|
+
{% block methods %}
|
|
8
|
+
|
|
9
|
+
{% if methods %}
|
|
10
|
+
.. rubric:: {{ _('Methods') }}
|
|
11
|
+
|
|
12
|
+
.. autosummary::
|
|
13
|
+
:toctree:
|
|
14
|
+
{% for item in methods %}
|
|
15
|
+
{% if not item in skipmethods %}
|
|
16
|
+
{% if name == 'Plotter' or item not in inherited_members %}
|
|
17
|
+
{{ name }}.{{ item }}
|
|
18
|
+
{% endif %}
|
|
19
|
+
{% endif %}
|
|
20
|
+
{%- endfor %}
|
|
21
|
+
{% endif %}
|
|
22
|
+
{% endblock %}
|
|
23
|
+
|
|
24
|
+
{% block attributes %}
|
|
25
|
+
{% if attributes %}
|
|
26
|
+
.. rubric:: {{ _('Attributes') }}
|
|
27
|
+
|
|
28
|
+
.. autosummary::
|
|
29
|
+
:toctree:
|
|
30
|
+
{% for item in attributes %}
|
|
31
|
+
{% if name == 'Plotter' or item not in inherited_members %}
|
|
32
|
+
{% if item.0 != item.upper().0 %}
|
|
33
|
+
{{ name }}.{{ item }}
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% endif %}
|
|
36
|
+
{%- endfor %}
|
|
37
|
+
{% endif %}
|
|
38
|
+
{% endblock %}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{{ fullname | escape | underline}}
|
|
2
|
+
|
|
3
|
+
.. automodule:: {{ fullname }}
|
|
4
|
+
|
|
5
|
+
{% block attributes %}
|
|
6
|
+
{% if attributes %}
|
|
7
|
+
.. rubric:: Module Attributes
|
|
8
|
+
|
|
9
|
+
.. autosummary::
|
|
10
|
+
:toctree:
|
|
11
|
+
{% for item in attributes %}
|
|
12
|
+
{{ item }}
|
|
13
|
+
{%- endfor %}
|
|
14
|
+
{% endif %}
|
|
15
|
+
{% endblock %}
|
|
16
|
+
|
|
17
|
+
{% block functions %}
|
|
18
|
+
{% if functions %}
|
|
19
|
+
.. rubric:: {{ _('Functions') }}
|
|
20
|
+
|
|
21
|
+
.. autosummary::
|
|
22
|
+
:toctree:
|
|
23
|
+
{% for item in functions %}
|
|
24
|
+
{{ item }}
|
|
25
|
+
{%- endfor %}
|
|
26
|
+
{% endif %}
|
|
27
|
+
{% endblock %}
|
|
28
|
+
|
|
29
|
+
{% block classes %}
|
|
30
|
+
{% if classes %}
|
|
31
|
+
.. rubric:: {{ _('Classes') }}
|
|
32
|
+
|
|
33
|
+
.. autosummary::
|
|
34
|
+
:toctree:
|
|
35
|
+
{% for item in classes %}
|
|
36
|
+
{{ item }}
|
|
37
|
+
{%- endfor %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% endblock %}
|
|
40
|
+
|
|
41
|
+
{% block exceptions %}
|
|
42
|
+
{% if exceptions %}
|
|
43
|
+
.. rubric:: {{ _('Exceptions') }}
|
|
44
|
+
|
|
45
|
+
.. autosummary::
|
|
46
|
+
:toctree:
|
|
47
|
+
{% for item in exceptions %}
|
|
48
|
+
{{ item }}
|
|
49
|
+
{%- endfor %}
|
|
50
|
+
{% endif %}
|
|
51
|
+
{% endblock %}
|
|
52
|
+
|
|
53
|
+
{% block modules %}
|
|
54
|
+
{% if modules %}
|
|
55
|
+
.. rubric:: Modules
|
|
56
|
+
|
|
57
|
+
.. autosummary::
|
|
58
|
+
:toctree:
|
|
59
|
+
:template:
|
|
60
|
+
:recursive:
|
|
61
|
+
{% for item in modules %}
|
|
62
|
+
{{ item }}
|
|
63
|
+
{%- endfor %}
|
|
64
|
+
{% endif %}
|
|
65
|
+
{% endblock %}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{{ fullname | escape | underline}}
|
|
2
|
+
|
|
3
|
+
.. currentmodule:: {{ module }}
|
|
4
|
+
|
|
5
|
+
.. autoclass:: {{ objname }}
|
|
6
|
+
|
|
7
|
+
{% block methods %}
|
|
8
|
+
|
|
9
|
+
{% if methods %}
|
|
10
|
+
.. rubric:: {{ _('Methods') }}
|
|
11
|
+
|
|
12
|
+
.. autosummary::
|
|
13
|
+
:toctree: _autosummary
|
|
14
|
+
{% for item in methods %}
|
|
15
|
+
{% if item != "__init__" %}
|
|
16
|
+
{{ name }}.{{ item }}
|
|
17
|
+
{% endif %}
|
|
18
|
+
{%- endfor %}
|
|
19
|
+
{% endif %}
|
|
20
|
+
{% endblock %}
|
|
21
|
+
|
|
22
|
+
{% block attributes %}
|
|
23
|
+
{% if attributes %}
|
|
24
|
+
.. rubric:: {{ _('Attributes') }}
|
|
25
|
+
|
|
26
|
+
.. autosummary::
|
|
27
|
+
:toctree: _autosummary
|
|
28
|
+
{% for item in attributes %}
|
|
29
|
+
{% if item.0 != item.upper().0 %}
|
|
30
|
+
{{ name }}.{{ item }}
|
|
31
|
+
{% endif %}
|
|
32
|
+
{%- endfor %}
|
|
33
|
+
{% endif %}
|
|
34
|
+
{% endblock %}
|