Hey all,
I am experiencing some issues trying to visualize vector fields in ParaView 5.11.1 when multiple functions are stored in a single XDMF file. Maybe this turns out to be a ParaView question, but my impression is that something is wrong with how I write the XDMF files.
Consider the following MWE that creates and writes 2 vector fields:
import dolfinx
import numpy as np
from dolfinx import fem, io
from mpi4py import MPI
from petsc4py import PETSc
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 16, 16)
V = fem.VectorFunctionSpace(mesh, ("CG", 1))
u = fem.Function(V, name="u")
v = fem.Function(V, name="v")
def f(x):
values = np.zeros((2, x.shape[1]), dtype=PETSc.ScalarType)
values[0] = x[1]*(1.0  x[1])
return values
u.interpolate(f)
u.vector.copy(v.vector)
v.vector.scale(2.0)
with io.XDMFFile(MPI.COMM_WORLD, "test.xdmf", "w") as xf:
xf.write_mesh(mesh)
xf.write_function(u, 0.0)
xf.write_function(v, 0.0)
In ParaView, selecting the Xdmf3ReaderT and XDMF Reader, the magnitude and component fields are correctly displayed (Xdmf3ReaderS does not display any values). Whenever multiple functions are stored in a single file, the functions are named u (partial)
, v (partial)
, etc – not sure if that’s intended?

Visualizing vectors (workaround):
Applying the Glyphs filter to visualize the vector fields does not work as expected: in the above example, depending on which field is selected as orientation, scale array and for colors, different errors occur. Both fields are shown together, the arrows are not scaled and/or not colored, etc.
Using theExtract Block
twice to extract and separate both fields allows correctly visualizing the vectors. But I’d expect this to work without this workaround. 
WarpByVector (no solution):
For a case of elasticity I want to warp the domain by a displacement vector field and to display the stresses or the velocity field on the warped domain.
Applying theWarpByVectors
filter only warps the field itself that was selected as the warping field, the other remains unchanged. Curiously, applying the filter will visualize both fields, the warped and the unwarped. UsingExtract Block
can separate both, but I couldn’t find a setup where I could visualize fieldv
warped by fieldu
.
This reads like a long ParaView question, but, again, my impression is that the functions are not written correctly.
Thank you for your input!