Visualization issue in Paraview with higher-order elements

Hi! I’ve encountered an issue when visualizing functions with polynomial order greater than 2 in Paraview. While the surface visualization (shown in the attached images using “Warp By Scalar”) works correctly for both 2nd and 3rd order functions, the “Plot Over Line” filter produces broken plots for functions with degree greater than two. This behavior occurs with both VTKFile and VTXWriter outputs.

Here’s a minimal working example that demonstrates the problem:

import dolfinx
from mpi4py import MPI

# Create mesh
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 4, 4, dolfinx.mesh.CellType.quadrilateral)

# Define functionspace and function with order 3
V = dolfinx.fem.functionspace(mesh, ("Lagrange", 3))
u = dolfinx.fem.Function(V)

# Interpolate cubic function
u.interpolate(lambda x: x[0] ** 3 * x[1] ** 3)

# Export using VTX
bp_writer_u = dolfinx.io.VTXWriter(mesh.comm, "results/u.bp", [u], engine="BP4")
bp_writer_u.write(0)

# Export using VTK
vtk_writer_u = dolfinx.io.VTKFile(mesh.comm, "results/u.pvd", "w")
vtk_writer_u.write_mesh(mesh, 0.0)
vtk_writer_u.write_function(u, 0.0)

When visualizing the results in Paraview:

  1. The surface plot using “Warp By Scalar” looks reasonable
  2. However, when plotting along the diagonal line from (0,0) to (1,1) using the “Plot Over Line” filter, the result shows a dotted, discontinuous representation which is not the exact cubic function that was interpolated
  3. The same setup with 2nd order elements produces smooth, continuous plots along this diagonal

With order=2:

With order:3:

Is this a known limitation of the VTK/VTX export, or am I missing something? Is there a way to achieve smooth visualization for higher-order elements?

My dolfinx version is 0.9.0, and I am using WSL. I have tested this on both the Windows and Linux versions of ParaView (6.0.0), and the issue persists in both environments.

Any insights would be appreciated! Thanks in advance.

I would advice to post this on the Paraview discourse (https://discourse.paraview.org/) as well, as this is a VTK/VTX issue, i.e. how the “Plot over line” filter interacts with higher order Lagrangian cell types in paraview: https://www.kitware.com/modeling-arbitrary-order-lagrange-finite-elements-in-the-visualization-toolkit/

The symptoms reported here sound similiar

I’ve posted this issue on the Paraview discourse here. I’ll post an update, if this gets resolved. Thanks again for the help!