This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
/
writepvtu.jl
59 lines (53 loc) · 1.5 KB
/
writepvtu.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using ..TicToc
"""
writepvtu(pvtuprefix, vtkprefixes, fieldnames, FT)
Write a pvtu file with the prefix 'pvtuprefix' for the collection of vtk files
given by 'vtkprefixes' using names of fields 'fieldnames'. The data in the
`vtu` files is of type `FT`.
"""
function writepvtu(pvtuprefix, vtkprefixes, fieldnames, FT)
open(pvtuprefix * ".pvtu", "w") do pvtufile
write(
pvtufile,
"""
<?xml version="1.0"?>
<VTKFile type="PUnstructuredGrid" version="0.1" compressor="vtkZLibDataCompressor" byte_order="LittleEndian">
<PUnstructuredGrid GhostLevel="0">
<PPoints>
<PDataArray type="$FT" Name="Position" NumberOfComponents="3" format="binary"/>
</PPoints>
<PPointData>
""",
)
for name in fieldnames
write(
pvtufile,
"""
<PDataArray type="$FT" Name="$name" format="binary"/>
""",
)
end
write(
pvtufile,
"""
</PPointData>
""",
)
for name in vtkprefixes
write(
pvtufile,
"""
<Piece Source="$name.vtu"/>
""",
)
end
write(
pvtufile,
"""
</PUnstructuredGrid>
</VTKFile>
""",
)
end
return nothing
end