简体   繁体   中英

Writing numpy array as VTK file

I have a 2D numpy array that I wish to export and write as a VTK file. I have tried the vtk package as well as PyEVTK package but am running into issues with both.

Thanks.

I believe this is what you're looking for:

from vtk.util import numpy_support
numpy_to_vtk(num_array, deep=0, array_type=None)

Is this what you asking for? It is easy to use but you have to know the connectivity of yourElements

import meshio 

yourNodes = np.array([...])
yourElements = np.array([...])
cells = [("triangle", yourElements )]
mesh = meshio.Mesh(yourNodes , cells )
mesh.write("foo.vtk")

yourElements start at 0 and not at 1!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM