WriteVTK.jl
This package allows to write VTK XML files for visualisation of multidimensional datasets using tools such as ParaView. A wide range of VTK formats is supported, including different kinds of structured and unstructured grids, as well as metadata files for describing time series or multi-block domains.
Installation
WriteVTK can be installed using the Julia package manager:
julia> ] add WriteVTK
Quick start
The vtk_grid
function is the entry point for creating different kinds
of VTK files.
In the simplest cases, one just passes coordinate information to this function.
WriteVTK.jl then determines the VTK format that is more adapted for the provided
data.
For instance, it is natural in Julia to describe a uniform three-dimensional grid (with regularly-spaced increments) as a set of ranges:
x = 0:0.1:1
y = 0:0.2:1
z = -1:0.05:1
This specific way of specifying coordinates is compatible with the image data
VTK format, which has the .vti
extension.
The following creates such a file, with some scalar data attached to each point:
vtk_grid("fields", x, y, z) do vtk
vtk["temperature"] = rand(length(x), length(y), length(z))
end
This will create a fields.vti
file with the data.
Note that the file extension should not be included in the filename, as it will
be attached automatically according to the dataset type.
By changing the coordinate specifications, the above can be naturally generalised to non-uniform grid spacings and to curvilinear and unstructured grids. In each case, the correct kind of VTK file will be generated.
Supported VTK formats
This package attempts to implement writers for all VTK XML formats described in the VTK specification. Note that legacy (non-XML) files are not supported.
Supported dataset formats include:
- image data (
.vti
), - rectilinear grid (
.vtr
), - structured (or curvilinear) grid (
.vts
), - unstructured grid (
.vtu
), - polydata (
.vtp
, a specific type of unstructured grid).
Moreover, the following metadata formats are supported:
- multiblock files (
.vtm
), - ParaView collections (
.pvd
, typically used for time series), - parallel files (
.pvt*
).
Further reading
See the documentation for more details on how to use this package.
Authors
This package is mainly written and maintained by Juan Ignacio Polanco, with many important contributions by Fredrik Ekre. Moreover, a number of authors have implemented additional functionality, and are acknowledged throughout the documentation.