DG fields in Paraview

I am working on some cohesive element formulation, relying heavily on the ‘Fenicsx Tours’, Cohesive zone modeling restricted to an interface — Computational Mechanics Numerical Tours with FEniCSx

My script is running, but I am totally unable to visualise the results in Paraview. Referring to the script czm_interface_only.py, it saves a czm.pvd file, plenty of .vtu files, as well as pvtu.

I can open the czm.pvd, but completely unable to find a field to ‘Warp by Vector’ by, to see the interface opening.

I appreciate this is a Paraview-centered question, but I hope somebody can help, as it also relates to how Dolfinx outputs DG fields.

Thanks

Have you taken a look at the procedure in Divergence conforming discontinuous Galerkin method for the Navier–Stokes equations # noqa — DOLFINx 0.10.0.post5 documentation ? I.e, export with VTXWriter. That DG export loads into paraview without issues, and allows for warp by vector.

VTKFIle should be able to store DG values, as illustrated with the following MWE:

from mpi4py import MPI
import dolfinx

mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
V = dolfinx.fem.functionspace(mesh, ("DG", 1, (mesh.geometry.dim,)))
u = dolfinx.fem.Function(V)

right_cells = dolfinx.mesh.locate_entities(mesh, mesh.topology.dim, lambda x: x[0]>0.5 - 1e-14)
u.interpolate(lambda x: (x[0], x[1]), cells0=right_cells)

with dolfinx.io.VTKFile(mesh.comm, "u.pvd", "w") as vtk:
    vtk.write_function(u)

yielding:


where the wireframe grid is the unwarped grid, while the solid bits is the warped version.

Thanks to all, much appreciated

Questions on different output formats (and their restrictions) pop up every now and then. Do you think you could give a short run down on the options and best practices?

Things wrt IO never seem to stabilize, there is always the N+1 formats. Here is a rundown as of Feb 2026:

The latest update of vtkhdf from kitware is at https://www.kitware.com/vtkhdf-file-format-2025-status-update/

1 Like