Hello!
I have made a very simple code to save point data + one point data array:
using WriteVTK
using Random
using Test
function write_vtp(filename::String, points, attribute)
polys = empty(MeshCell{WriteVTK.PolyData.Polys,UnitRange{Int64}}[])
verts = empty(MeshCell{WriteVTK.PolyData.Verts,UnitRange{Int64}}[])
# Note: the order of verts, lines, polys and strips is not important.
# One doesn't even need to pass all of them.
all_cells = (verts, polys)
fname = filename * "_2D"
vtk = vtk_grid(fname, points, all_cells..., compress=true, append=false)
vtk["my_point_data"] = attribute;
vtk_save(vtk)
end
function main()
Np = 1280
points = rand(2,Np);
filename = "polydata"
attribute = [randn() for i = 1, j = 1:Np];
@time filenames = write_vtp(filename, points, attribute)
end
main()
Running this code though and just benchmarking using @time:
5.363723 seconds (47.69 M allocations: 1.383 GiB, 4.40% gc time)
Which is quite poor considering N = 1280 - I believe I am doing something wrong, but I cannot figure it out. Would anyone know why?
Kind regards