prs513rosewood/uvw

Write Vector Data to VTK File

jettrich opened this issue · 1 comments

Hi,

I'm using uvw successfully to write structured scalar data to vtr-file, and I'm able to open and visualize the data with e.g. Paraview. Now I have vector valued data, e.g. the velocity, which I have stored in three diffrerent numpy arrays for the x,y,z components of the velocity, here U, V, W respectively. I can successfully write the three different ndarrays of shape (nx, ny, nz) as scalar data, and I build vector data from that inside Paraview. I have tried different reshape/ravel/dstack variants (e.g. "velocity=numpy.dstack((U.ravel(), V.ravel(), W.ravel()))"), but I didn't succeed and I have no idea of "how to write the velocity vector, which can easily be build from the components, to the VTK file, such that I can access the vector data in Paraview!?

Please, any help is highly appreciated!

Kind Regards
Jörg

Sorry for the late response, somehow I'm not getting notifications on this repo. To answer your question, there's an example in the README file that writes an array with 3x3 components per point (so a total of 3 spatial dimensions and 2 additional dimensions for vector/tensor components). help(uvw.DataArray) will give you some indication on how to specify which axis is a spatial dimension and which is a component. Your example does not work because unraveling the arrays collapses the axes that give the spatial dimension.