# Vtkfile creates pvd and vtu

**URL:** <https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511>\
**Category:** I/O\
**Created:** [June 12, 2020, 7:53pm UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511 "2020-06-12T19:53:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![E\_P](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/e_p/32/1356_2.png) [@E\_P](https://fenicsproject.discourse.group/u/E_P)\
**Post date:** [June 12, 2020, 7:53pm UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/1 "2020-06-12T19:53:17Z")

</div>

Hi there,

It seems like some versions of Fenics do not support interactive() command anymore, also there are some issues with vtkfile creation, e.g.

```
u = Function(V)
t = 0
for n in range(num_steps):
t += dt
u_y.t = t
solve(a == L, u, bc)
#plot(u)
vtkfile = File("test.pvd")
vtkfile << (u, t)
u_n.assign(u)
#interactive()

```

This creates two files pvd & vtu files, when I have opened pvd file in ParaView, then some errors come up, as well as no results can be visualized; when opening pvd file, it looks like xml file

```
<?xml version="1.0"?>
<VTKFile type="Collection" version="0.1">
  <Collection>
    <DataSet timestep="1.9999999999999998" part="0" file="test000000.vtu" />
  </Collection>
</VTKFile>

```

Has anyone faced such issue before ?

Many thanks,  
Evgeny.

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [June 12, 2020, 8:30pm UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/2 "2020-06-12T20:30:17Z")

</div>

> [@E\_P](#):
>
> ```auto
> vtkfile = File("test.pvd")
> vtkfile << (u, t)
> 
> ```

Have you tried using `XDMF` format, namely:

```python
file_u = XDMFFile(MPI.comm_world, "test.xdmf")
file_u.parameters["flush_output"] = True
file_u.parameters["functions_share_mesh"] = True
file_u.parameters["rewrite_function_mesh"] = False
...
for n in range(num_steps):
    t += dt
    u_y.t = t
    solve(a == L, u, bc)
    file_u.write(u, t) # or `write_checkpoint` for DG/CG-2 and higher order spaces

```

The corresponding `test.xdmf` file can then be opened in `paraview` for visualization. This should also work seamlessly when writing to/reading from a file in parallel.

---

<div class="post-metadata">

**Author:** ![E\_P](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/e_p/32/1356_2.png) [@E\_P](https://fenicsproject.discourse.group/u/E_P)\
**Post date:** [June 12, 2020, 8:40pm UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/3 "2020-06-12T20:40:45Z")

</div>

Many thanks for your message. Never tried this, because I have done as the tutorial says so far, e.g., Fenics tutorial says as follows:

> This line is called in each time step, resulting in the creation of a new file  
> with suffix .vtu containing all data for the time step (the mesh and the  
> vertex values). The file heat\_gaussian/solution.pvd will contain the time  
> values and references to the .vtu file, which means that the .pvd file will  
> be a single small file that points to a large number of .vtu files containing  
> the actual data.

Indeed, what I have got these two files - pvd and vtu, though the challenge is how to visualize data in paraview, when opening only pvd file, paraview says the following error:

> ERROR: In C:\bbd\ecd3383f\build\superbuild\paraview\src\VTK\IO\XML\vtkXMLUnstructuredDataReader.cxx, line 649  
> vtkXMLUnstructuredGridReader (0000025ED2E4D900): Error reading cell offsets: Unsupported array type: vtkUnsignedIntArray

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [June 12, 2020, 8:53pm UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/4 "2020-06-12T20:53:16Z")

</div>

> [@E\_P](#):
>
> Error reading cell offsets: Unsupported array type: vtkUnsignedIntArray

I would suggest trying `xdmf` as explained above. Also if you are using `Paraview-5.8.0` then it could be a bug, see [this](https://gitlab.kitware.com/paraview/paraview/-/issues/19698), although it seems that it is [fixed](https://gitlab.kitware.com/paraview/paraview/-/merge_requests/3982)

---

<div class="post-metadata">

**Author:** ![E\_P](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/e_p/32/1356_2.png) [@E\_P](https://fenicsproject.discourse.group/u/E_P)\
**Post date:** [June 13, 2020, 5:13am UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/5 "2020-06-13T05:13:09Z")

</div>

Many thanks, your suggestion works very well, though I still could not get this format although if Fenics / python can generate this format, then eventually will understand how this works out, it provides xdmf & h5 files, these both files are required, or just xdmf for further paraview processing ?

Also have noticed that paraview creates colormap and put f\_13 variable, this supposed to be u values, in terms of my particular variational formulation; this is because of a way how output file is generated?

Many thanks,  
Evgeny.

---

<div class="post-metadata">

**Author:** ![bhaveshshrimali](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/bhaveshshrimali/32/124_2.png) [@bhaveshshrimali](https://fenicsproject.discourse.group/u/bhaveshshrimali)\
**Post date:** [June 13, 2020, 5:22am UTC](https://fenicsproject.discourse.group/t/vtkfile-creates-pvd-and-vtu/3511/6 "2020-06-13T05:22:04Z")

</div>

> [@E\_P](#):
>
> these both files are required, or just xdmf for further paraview processing ?

Hi,  
Both the `xdmf` and `h5` files are required. `xdmf` contains the attributes and `h5` is the actual binary that contains the data. As for the name `f13`, you can either manually change it inside paraview, or name the function simply by using

```python
u = Function(V, name="u")

```
