JuliaVTK / ReadVTK.jl

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

get_field(vtk) function added to get FieldData from VTK #42

Open andresegido opened 9 months ago

andresegido commented 9 months ago

Introduced functions 'get_field' and 'field_data' in order to be able to read FieldData from VTK files.

andresegido commented 9 months ago

Thanks for the suggestions! I just introduced them into my last commit.

ranocha commented 9 months ago

Thanks a lot for this contribution 🙏! This PR seems to be on the right track. There are some usability issues open (see the comments), and it would be great if you could add some simple tests for the new functionality.

Thanks a lot also from my side! Could you please add some tests of the new functionality? See test/runtests.jl

andresegido commented 9 months ago

Thanks a lot for this contribution 🙏! This PR seems to be on the right track. There are some usability issues open (see the comments), and it would be great if you could add some simple tests for the new functionality.

Thanks a lot also from my side! Could you please add some tests of the new functionality? See test/runtests.jl

Hi! I don't have much experiences writing tests, and much less in Julia; so I'm not sure about where to start...

Also, I did a quick check through the vtk files you use for your tests and none of them have any field data, so using them would not be desirable for such a test.

I have done some work with a dummy vtk file I have locally and it works as expected:

vtk = VTKFile("testing/Wing.vtu") fieldData = ReadVTK.get_field_data(vtk) nx = get_data(fieldData["nx"])

In this case, fieldData behaves as a ReadVTK.VTKData and nx reads the expected value.

This might help you appending some field data to one of your vtk files and preparing a test.

ranocha commented 9 months ago

The example files are collected in the repository https://github.com/JuliaVTK/ReadVTK_examples. You can open a PR there and upload a new file containing some field data. When that PR is merged, you can update the commit hash in https://github.com/JuliaVTK/ReadVTK.jl/blob/7668d43a85918756719d62bf95e1085cdf539304/test/runtests.jl#L5-L9 accordingly and write a proper test here.