I am trying to visualise a vector field in Paraview. I am using Raviart Thomas elements in FEniCSx, and the code for a basis function in the RT space produces the following plot.

I think this is the correct visualisation of the RT basis function, but I would like to have only one arrow per node. Is there a way to sum the vectors at each node?

Many thanks,
Katie

Code:

import numpy as np
import ufl
from dolfinx import io, fem, mesh
from mpi4py import MPI
domain = mesh.create_unit_square(MPI.COMM_WORLD, 8, 8, mesh.CellType.triangle)
V = fem.FunctionSpace(domain, ("RT", 1))
f = fem.Function(V)
f.x.array[:] = np.zeros(len(f.x.array))
f.x.array[40] = 1.
DG_element = ufl.VectorElement("DG", domain.ufl_cell(), degree=1, dim=2)
V_DG = fem.FunctionSpace(domain, DG_element)
f_DG = fem.Function(V_DG)
f_DG.interpolate(f)
f_DG.name = "Basis Function"
with io.VTXWriter(domain.comm, "RT_basis_degree1.bp", [f_DG], "BP4") as f:
f.write(0.0)

It is quite clear from the definition of Raviart-Thomas:

that it is not continuous over element boundaries:

Components normal to facets are continuous

Thus to visualize with paraview, you have to interpolate into a discontinuous Lagrange space (as you have done). Therefore you get degrees of freedom for every cell. For DG one, each cell will have a degree of freedom at a vertex, and there will thus be four different values for the basis functions at a vertex shared between four cells.

I know a-priori that the vector field should be continuous and smooth, so that is why I had considered averaging the vectors at each point to be a reasonable thing to do. Is it not?

Thank you for the advice, I will try plotting a subset of the glyphs!

When you chose Raviart Thomas, you do not enforce tangential continuity, thus the resulting field is only continuous in normal direction if you do not add additional enforcement.