JuliaVTK / ReadVTK.jl

Julia package for reading VTK XML files
https://juliavtk.github.io/ReadVTK.jl
MIT License
30 stars 9 forks source link

How to read FieldData? #54

Open svretina opened 5 months ago

svretina commented 5 months ago

Hi, I am experimenting with the WriteVTK.jl and ReadVTK.jl. I would like to store some 3D scalar field data and the velocity and acceleration of a particle. What I am using to write the vtk file is something like the following:

vtk_grid(dataset, xcoord, ycoord, zcoord) do vtk
                    vtk["Phi"] = statevector[:, :, :, 1]
                    vtk["Pi"] = statevector[:, :, :, 2]
                    vtk["Psix"] = statevector[:, :, :, 3]
                    vtk["Psiy"] = statevector[:, :, :, 4]
                    vtk["Psiz"] = statevector[:, :, :, 5]
                    vtk["Position"] = [xcoord[i], ycoord[j], zcoord[k]]
                    vtk["Velocity"] = [vx, vy, vz]
                end

I can see that the info is written in the vti file correctly. Later in VisIt or with ReadVTK.jl I cannot retrieve the data for the Position and Velocity which are FieldData. How could I read these data?

svretina commented 5 months ago

just saw that there is a PR regarding this issue. It should provide the functionality I am seeking.

ranocha commented 5 months ago

Since it looks like the PR you mentioned is stalled due to a lack of examples/testing, you're welcome to contribute by helping out there.

svretina commented 4 months ago

It seems to be an easy task to add some tests, since the functions are relatively simple. But I have not done a PR again, is there something to read to guide how to proceed with it?

sloede commented 4 months ago

TBH, I have not done it myself this way, but I imagine you could clone the fork used for #42, push the branch in question to your own fork, and then add your tests on top of it. Just to avoid redundant work, it would be good to communicate your plans in #42 such that everyone knows you are picking up there.

svretina commented 4 months ago

I cloned your pr and had a look at the tests. Should I modify the example repo to add field data to it, or should I create an example file for each VTKData type which would include only some field data and test them instead? Some guidance would be much appreciated! its also a learning process for me.

sloede commented 4 months ago

I don't know the details of how much as required to test this properly, but assuming that field data is stored similarly for the various mesh file types, I'd say that adding a single file with field data and reading it should suffice.