Vtkfile creates pvd and vtu

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.

Have you tried using XDMF format, namely:

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.

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

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, although it seems that it is fixed

2 Likes

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.

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

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