ReadVTK.jl icon indicating copy to clipboard operation
ReadVTK.jl copied to clipboard

How to read FieldData?

Open svretina opened this issue 2 years ago • 6 comments

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 avatar Feb 19 '24 13:02 svretina

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

svretina avatar Feb 19 '24 14:02 svretina

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.

ranocha avatar Feb 21 '24 09:02 ranocha

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?

svretina avatar Feb 26 '24 11:02 svretina

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.

sloede avatar Feb 26 '24 11:02 sloede

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.

svretina avatar Feb 26 '24 13:02 svretina

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.

sloede avatar Feb 26 '24 14:02 sloede