VTK UnstructuredGrid#
.vtu read + write eager
Summary of the specification#
.vtu is the XML serial form of a VTK UnstructuredGrid: an arbitrary mix of cell types in one dataset. A <VTKFile type="UnstructuredGrid"> root holds an <UnstructuredGrid> with one or more <Piece> elements, each declaring NumberOfPoints and NumberOfCells. A piece carries <Points> with a three-component coordinate DataArray, and <Cells> with three named arrays — connectivity, offsets and types — where types holds one VTK cell type code per cell. <PointData> and <CellData> hold named attribute arrays. Every DataArray is inline ASCII, inline base64, or a reference into a single appended binary blob, optionally zlib-compressed.
Specification at a glance#
root |
<VTKFile type=”UnstructuredGrid”> |
pieces |
one or more <Piece NumberOfPoints= NumberOfCells=> |
cells |
connectivity, offsets and types DataArrays |
cell types |
one VTK type code per cell |
encodings |
ascii, base64, appended (raw or base64), optionally zlib-compressed |
indices |
0-based |
Reading#
import polyxios as px
mesh = px.read("grid.vtu")
mesh.element_types # mixed cell types, mapped from the VTK codes
Writing#
px.write(mesh, "out.vtu") # base64 payloads (default)
px.write(mesh, "out.vtu", binary=False) # inline ASCII
option |
meaning |
|---|---|
|
|
Quirks worth knowing#
Multiple
<Piece>elements are concatenated into onePolyData, with each piece’s connectivity shifted by the running vertex count.VTK cell type codes with no polyxios equivalent are dropped rather than guessed at.
lazy=TrueraisesLazyReadError; the payload may be compressed or base64-encoded, neither of which can be memory-mapped.Header counts are validated against the file size before any array is allocated.
See also
Supported formats — the full format table. VTK PolyData — the XML PolyData sibling.