-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple times in one .vtu file? #24
Comments
Hi! Sorry for the late reply. Unfortunately, as far as I know, it's not possible to do such thing with VTK files. One possible workaround would be to save grid data to a separate file, which is written only once, and then "include" the file in each generated VTK file. I'm not really sure if that would work though. I tested using some XML syntax that should allow including other XML files, but that didn't work. I still need to make a few more tests. |
Two ideas that also would allow for writing the grid only once, similar as @jipolanco's idea about including the grid information, but these might be easier to implement? Idea 1: Add a copy method to be able to copy a vtkfile: pvd = paraview_collection("output_pvd")
vtk = vtk_grid("vtkgrid", points, cells)
for i in 1:n_timesteps
u = solve() # solve the problem for given timestep
# copy the "base" file containing the grid might be faster than writing again
vtkfile = copy(vtk)
# although we have to rename the vtkfile, so maybe a copy like this instead
vtkfile = copy(vtk, "timestep$(i)")
vtk_point_data(vtkfile, u, "u") # write solution u to the file
collection_add_timestep(pvd, vtkfile, i)
end
Idea 2: Implement a way to reset the file, removing everything except the grid information from the buffer. This would (if it is possible to do) probably be faster then option 1, since it would only delete data. pvd = paraview_collection("output_pvd")
vtk = vtk_grid("vtkgrid", points, cells)
for i in 1:n_timesteps
u = solve() # solve the problem for given timestep
# reset! the file to the "base" file
reset!(vtk)
# rename variant
reset!(vtk, "timestep$(i)")
vtk_point_data(vtkfile, u, "u") # write solution u to the file
collection_add_timestep(pvd, vtkfile, i)
end
of course none of these options saves any memory in the end, since the grid information is stored in each |
We can now do this with VTK-HDF5 for ImageData and Unstructured grids. Not sure how to best describe the interface to specify a vtk-hdf file in this library, but if anyone has ideas I can attempt to add it. |
@lucasbanting It would be very interesting to add a VTK-HDF5 interface. However, from looking at some examples it's not very clear to me how one would include multiple times in a single VTK-HDF5 file. Do you have any examples? Does it involve creating separate HDF5 groups for each timestep or something like that? As for a possible interface, I'd propose to extend the current interface so that saved_files = vtk_grid(VTKHDF5(), filename, points..., [cells]; kws...) do vtk
# add datasets here...
end In any case, I'd rather not include HDF5.jl as a hard dependency to WriteVTK.jl, but instead to optionally support VTK-HDF5 output using Requires.jl or the new package extensions in Julia 1.9. |
I was just going off of: https://www.kitware.com/vtk-hdf-reader/ , and saw where it said it is intended to replace XDMF. |
I am not sure if this is possible with VTK, but it would be great to have one file that stores an unstructured mesh and data on the mesh at multiple times. For example, it would be great to do something like:
where point data is being stored for several (10, in this example) times within one .vtu file. I am currently wasting a lot of space (and CPU time) storing the same grid in several hundred large files where each file contains the grid and the data for one time. The PVD example addresses the issue of having data at multiple times, but doesn't deal with the redundancy of storing the grid in each file.
I am not sure if VTK supports storing data for multiple times in one file like this. If it is supported by VTK, having support in WriteVTK.jl would be amazing. Thanks for your work on WriteVTK -- I love it!
The text was updated successfully, but these errors were encountered: