VTK StructuredGrid#

.vts read + write eager

Summary of the specification#

.vts is the XML serial form of a VTK StructuredGrid: a curvilinear grid with an explicit coordinate per node but implicit connectivity. A <VTKFile type="StructuredGrid"> root holds a <StructuredGrid> whose WholeExtent gives the index range on each axis as i0 i1 j0 j1 k0 k1. Each <Piece> restates its own Extent and carries a <Points> DataArray listing every node’s coordinates in i-fastest order. There is no connectivity array: the cells are the hexahedra implied by the extent. <PointData> and <CellData> hold named attribute arrays, encoded the same way as any other VTK XML file.

Specification at a glance#

root

<VTKFile type=”StructuredGrid”>

extent

WholeExtent=”i0 i1 j0 j1 k0 k1”

points

explicit coordinates, i-fastest ordering

connectivity

implicit; cells follow from the extent

encodings

ascii, base64, appended (raw or base64), optionally zlib-compressed

Reading#

import polyxios as px

mesh = px.read("curvilinear.vts")
mesh.element_types     # hexahedra expanded from the extent

Writing#

px.write(mesh, "out.vts")                 # base64 payloads (default)
px.write(mesh, "out.vts", binary=False)   # inline ASCII

option

meaning

binary

True (the default) writes base64-encoded payloads; False writes inline ASCII.

Quirks worth knowing#

  • The implicit grid is expanded to explicit hexahedral connectivity on read, so the resulting PolyData carries real elements rather than an extent.

  • That expansion is what makes a structured file cost the same as an unstructured one in memory; a large extent expands to a large connectivity array.

  • lazy=True raises LazyReadError.

  • Header counts are validated against the file size before any array is allocated.

See also

Supported formats — the full format table. VTK RectilinearGrid — the axis-aligned rectilinear sibling.