meshio网格数据格式转换工具
meshio 是一个网格格式的输入/输出转换工具,既可以进行格式转换,也可以在 python 中调用相应函数。
支持以下格式的互转化:
- Abaqus (
.inp) - ANSYS msh (
.msh), - AVS-UCD (
.avs) - CGNS (
.cgns) - DOLFIN
- XML (
.xml) - Exodus (
.e,.exo) - FLAC3D (
.f3grid) - H5M (
.h5m) - Kratos/MDPA (
.mdpa), - Medit (
.mesh,.meshb), - MED/Salome (
.med), - Nastran (bulk data,
.bdf,.fem,.nas), - Netgen (
.vol,.vol.gz), - Neuroglancer precomputed format, Gmsh (format versions 2.2, 4.0, and 4.1,
.msh), - OBJ (
.obj), - OFF (
.off), - PERMAS (
.post,.post.gz,.dato,.dato.gz), - PLY (
.ply), - STL (
.stl), - Tecplot .dat
- TetGen .node/.ele
- SVG (2D output only) (
.svg), - SU2 (
.su2) - UGRID (
.ugrid) - VTK (
.vtk) - VTU (
.vtu) - WKT (TIN) (
.wkt) - XDMF (
.xdmf,.xmf)
用例
使用其中之一安装:
pip install meshio[all]
conda install -c conda-forge meshio
([all]拉入所有可选依赖项。默认情况下,meshio 仅使用 numpy。)
然后可以使用命令行工具
meshio convert input.msh output.vtk # convert between two formats
meshio info input.xdmf # show some info about the mesh
meshio compress input.vtu # compress the mesh file
meshio decompress input.vtu # decompress the mesh file
meshio binary input.msh # convert to binary format
meshio ascii input.msh # convert to ASCII format
Python 中的用法:
import meshio
mesh = meshio.read(
filename, # string, os.PathLike, or a buffer/open file
# file_format="stl", # optional if filename is a path; inferred from extension
# see meshio-convert -h for all possible formats
)
# mesh.points, mesh.cells, mesh.cells_dict, ...
评论
