1

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.

1
  • 2
    Welcome to Stack Overflow! Please take the tour, read what's on-topic here and How to Ask, and provide a minimal reproducible example. "Implement this feature for me" is off-topic for this site. You have to make an honest attempt, and then ask a specific question about your algorithm or technique.
    – Stefan
    Commented Oct 17, 2020 at 6:09

2 Answers 2

1

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

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!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.