Sometimes you need to display tensors in paraview, and for that reason the VTK ASCII file format is perfect. You can easily write this by hand even! However, the documentation is bad on it and it took me quite some time to figure out how to write tensors by hand, thus here is an explanation for the future - when I again need it and cannot find the documentation...
The VTK format knows two kinds of notations: full 2nd rank tensors and symmetric 2nd rank tensors. A 2nd rank tensor can be written as a matrix with its components like this:
Now, the ordering in the VTK file for
TENSOR (full tensor) is:
00 01 02 10 11 12 20 21 22
The ordering for the
TENSOR6 (symmetric tensor) is:
00 11 22 01 12 02
To see this in action, here are two equivalent files:
# vtk DataFile Version 2.0 HMA Analysis ASCII DATASET UNSTRUCTURED_GRID POINTS 1 float 1.23 2.3556 3.4525 POINT_DATA 1 TENSORS6 OrientTensor float 1.5 1.8 2.0 2.5 0.8 3.4
# vtk DataFile Version 2.0 HMA Analysis ASCII DATASET UNSTRUCTURED_GRID POINTS 1 float 1.23 2.3556 3.4525 POINT_DATA 1 TENSORS OrientTensor float 1.5 2.5 3.4 2.5 1.8 0.8 3.4 0.8 2.0
Note: You can also add tensors to
CELL_DATA, but then they can only be
displayed in paraview if you use the
Cell Data to Point Data filter.