Writing points to vtk with WriteVTK.jl

Hi, the above Python code exports an unstructured dataset (.vtu format), where each point corresponds to a “vertex” cell.

Unfortunately the equivalent in WriteVTK is a bit more verbose, as there is no direct analogous to pointsToVTK (but feel free to open an issue or PR for that!). For reference you should look at the unstructured datasets section of the README.

The following code is the equivalent to your example in Julia:

using WriteVTK

npoints = 100
x = rand(npoints)
y = rand(npoints)
z = rand(npoints)
pressure = rand(npoints)
temp = rand(npoints)
cells = [MeshCell(VTKCellTypes.VTK_VERTEX, (i, )) for i = 1:npoints]
vtk_grid("./points", x, y, z, cells) do vtk
    vtk["pressure", VTKPointData()] = pressure
    vtk["temp", VTKPointData()] = temp
end
4 Likes