# VTU file format

**URL:** https://discourse.paraview.org/t/vtu-file-format/5429
**Category:** ParaView Support
**Created:** [September 26, 2020, 9:13pm UTC](https://discourse.paraview.org/t/vtu-file-format/5429 "2020-09-26T21:13:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [September 26, 2020, 9:13pm UTC](https://discourse.paraview.org/t/vtu-file-format/5429/1 "2020-09-26T21:13:26Z")

</div>

I managed to write a finite element post-processor with vtk, however, it is my understanding that:

1. Vtk is obsolete, and better to use vtu.
2. I ould not find a documentation for file format for vtu as this [one for vtk](http://vtk.org/VTK/img/file-formats.pdf)
3. I have to use vtu to assign names to the components of a tensor (3x3)

Can someone kindly confirm/comment on the above?

thanks

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [September 27, 2020, 10:10pm UTC](https://discourse.paraview.org/t/vtu-file-format/5429/2 "2020-09-27T22:10:03Z")

</div>

If the legacy VTK (.vtk) file format suits your needs, you should be OK using it. Although legacy, I don’t think there are any plans to deprecate this file format. It is still used quite a bit.

Also, if you want to use the newer XML formats, [the document you referenced](http://vtk.org/VTK/img/file-formats.pdf) documents both the legacy .vtk format and the XML formats. The XML documentation starts after the legacy VTK format starting at the bottom of page 11.

---

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [September 28, 2020, 6:01am UTC](https://discourse.paraview.org/t/vtu-file-format/5429/3 "2020-09-28T06:01:26Z")

</div>

OK., XML is very similar to Latex (or JSON) with which I am familiar. It seems to be geared for document (and not data) preparation, but I can see how it can be used in this context.

Is there “out there” an example of an xml file to represent unstructured data, cells, vectors and tensors such as the following:

# vtk DataFile Version 3.0

Increment No. 1  
ASCII  
DATASET UNSTRUCTURED\_GRID  
POINTS 3241 float  
0.000000e+00 0.000000e+00 0.000000e+00  
…  
CELLS 2967 24150  
8 0 26 156 548 51 348 945 1624  
…  
4 20 312 1603 331  
…  
5 1009 103 8 185 3198  
CELL\_TYPES 2967  
11  
…  
10  
…  
14  
POINT\_DATA 3241  
VECTORS Node\_type float  
0.000000e+00 0.000000e+00 0.000000e+00  
…  
VECTORS Displacements float  
0.000000e+00 0.000000e+00 0.000000e+00  
…  
SCALARS VonMises float  
LOOKUP\_TABLE VonMises  
1.132817e+01  
…  
TENSORS Cauchy\_Stress float  
-1.136000e+01 -1.728000e-03 2.264000e-02  
-1.728000e-03 -1.138000e+01 2.474000e-03  
2.264000e-02 2.474000e-03 -4.398000e-02  
…

---

<div class="post-metadata">

### Author: ![olesenm](https://discourse.paraview.org/user_avatar/discourse.paraview.org/olesenm/32/17416_2.png) [@olesenm](https://discourse.paraview.org/u/olesenm)
#### Post date: [September 28, 2020, 7:15am UTC](https://discourse.paraview.org/t/vtu-file-format/5429/4 "2020-09-28T07:15:18Z")

</div>

Easiest - load your data in ParaView.

- File/Save Data… choose the vtu format with Data Mode “Ascii” - this should give you a good idea.

The output will include many additional things that you can skip (eg, the RangeMin, RangeMax).

Assuming you only have non-polyhedrals, generating the cells is fairly easy. In the Legacy format each entry in CELLS is prefixed by its size, Eg,

```auto
8 0 26 156 548 51 348 945 1624
4 20 312 1603 331

```

In the xml format this would be represented by two arrays. The `connectivity` is the list of vertices for the cells and the `offsets` are the cumulative _end_ of the connectivity lists.  
Eg,

```auto
<Cells>
    <DataArray type="Int32" Name="connectivity" format="ascii">
0 26 156 548 51 348 945 1624 # <- Hex
20 312 1603 331 # <- Tet
...
    </DataArray>
    <DataArray type="Int32" Name="offsets" format="ascii">
8 12 ...
    </DataArray>
    <DataArray type="UInt8" Name="types" format="ascii" >
...
    </DataArray>
</Cells>

```

---

<div class="post-metadata">

### Author: ![Victor\_Saouma](https://discourse.paraview.org/user_avatar/discourse.paraview.org/victor_saouma/32/4946_2.png) [@Victor\_Saouma](https://discourse.paraview.org/u/Victor_Saouma)
#### Post date: [September 28, 2020, 4:24pm UTC](https://discourse.paraview.org/t/vtu-file-format/5429/5 "2020-09-28T16:24:15Z")

</div>

Thanks, but I am using Paraview 5.8.1

I do not see any option for vtu format with Data Mode “Ascii”

 ![junk](https://discourse.paraview.org/uploads/default/original/2X/6/6e178642fd735df1c5324c1fb38c9184404215be.png)  
Not sure what may be wrong.

Thanks for your help,

victor

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [September 28, 2020, 7:28pm UTC](https://discourse.paraview.org/t/vtu-file-format/5429/6 "2020-09-28T19:28:14Z")

</div>

Select `VTK Unstructured Grid Files (*.vtu)` and choose a filename. Then click `OK`. Before saving the file, ParaView will pop up a second dialog box for options for that file format. In that second dialog box, select `Data Mode` to `Ascii`.

 ![2020-09-28_13-26-34](https://discourse.paraview.org/uploads/default/original/2X/2/2f2e53cf222faafaa0063b5fb6f68c4054ec5782.jpeg)
