跳转到主要内容

从LS-DYNA decks中读取节点和元素。

项目描述

LS-DYNA Mesh Reader

此库可用于读取存储在关键字(*.k,*.key,*.dyn)文件中的LS-DYNA网格,也称为关键字格式“输入牌”。该存储库的完整文档可在lsdyna-mesh-reader 文档中找到。

许多示例文件是从LS-DYNA 示例的优秀文档中获得的。

动机

尽管LS-DYNA非常受欢迎,但似乎没有关键字文件的读取器。我需要一个用于封闭源项目的读取器,并希望这能帮助到其他也希望读取这些文件的人。它借鉴了mapdl-archive,因为MAPDL在写入FEM时也遵循许多相同的FORTRAN约定。

安装

使用

pip install lsdyna-mesh-reader[pyvista]

如果您只需要节点和元素数组,而不需要任何VTK功能(例如绘图或UnstructuredGrid表示),请使用以下命令安装基本库:

pip install lsdyna-mesh-reader

示例

在通过基本示例之前,让我们谈谈这些“牌组”是如何组织的。每个关键字文件包含描述“卡片”部分开始的“关键字”。这个术语可以追溯到1976年DYNA3D开发的时候,那时程序是写在穿孔卡片上的。

要读取节点和元素,我们必须读取一个或多个以*NODE*ELEMENT_SOLID开头的节点和元素部分。这个库将这些原始部分以及解析部分作为更高层次的概念加载。

让我们先加载接触侵蚀I示例牌组。

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

现在我们可以检查节点部分中的一个

>>> 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
...

我们可以直接访问节点部分的节点ID和数组

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.        ]])

同样可以针对固体和壳体元素部分执行相同的操作。

>>> 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)

为了提高效率,元素存储为单个连续数组,可以通过以下方式拆分

>>> 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),
...
]

如果您已安装pyvista或使用pip install lsdyna-mesh-reader[pyvista]安装了库,您可以将网格转换为单个非结构化网格

>>> 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

这使得您可以通过PyVista对网格进行绘图、保存或执行其他操作。例如,您可以绘制生成的网格。以下是一个使用雅力士静态悬挂系统加载示例的完整示例。

>>> 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

注意事项和限制

目前,对这个库进行的测试有限,您可能会发现它无法加载复杂的或简单的关键字牌组。

此外,这个读取器只支持以下关键字

  • *NODE
  • *ELEMENT_SHELL
  • *ELEMENT_SOLID
  • *ELEMENT_TSHELL(注意:编码为固体部分的章节)

VTK UnstructuredGrid只包含底层LS-DYNA元素的线性元素转换,并支持VTK_QUADVTK_TRIANGLEVTK_TETRAVTK_WEDGEVTK_HEXAHEDRAL

问题和贡献

请随时在这个存储库中打开一个问题,提出您希望我添加的功能或需要修复的错误。

如果您想做出贡献,请参阅CONTRIBUTING.md

许可证

源代码和内容受MIT许可协议保护,但LS-DYNA工件保留其原始的LS-DYNA和Ansys许可证。

请注意,这里使用的示例文件是从LS-DYNA示例下载的,并且具有网站上注明的以下使用许可

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.

项目详细信息


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码发行版

lsdyna-mesh-reader-0.1.3.tar.gz (648.0 kB 查看哈希值

上传

构建发行版

lsdyna_mesh_reader-0.1.3-cp312-cp312-win_amd64.whl (719.6 kB 查看哈希值

上传于 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 查看哈希值)

上传于 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 查看哈希值)

上传于 CPython 3.12 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp312-cp312-macosx_10_14_x86_64.whl (716.2 kB 查看哈希值)

上传于 CPython 3.12 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp311-cp311-win_amd64.whl (721.4 kB 查看哈希值)

上传于 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 查看哈希值)

上传于 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 查看哈希值)

上传于 CPython 3.11 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp311-cp311-macosx_10_14_x86_64.whl (719.0 kB 查看哈希值)

上传于 CPython 3.11 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp310-cp310-win_amd64.whl (721.6 kB 查看哈希值)

上传于 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 查看哈希值)

上传于 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 查看哈希值)

上传于 CPython 3.10 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp310-cp310-macosx_10_14_x86_64.whl (719.2 kB 查看哈希值)

上传时间 CPython 3.10 macOS 10.14+ x86-64

lsdyna_mesh_reader-0.1.3-cp39-cp39-win_amd64.whl (721.9 kB 查看哈希值)

上传时间 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 查看哈希值)

上传时间 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 查看哈希值)

上传时间 CPython 3.9 macOS 11.0+ ARM64

lsdyna_mesh_reader-0.1.3-cp39-cp39-macosx_10_14_x86_64.whl (719.5 kB 查看哈希值)

上传时间 CPython 3.9 macOS 10.14+ x86-64

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面