Visualize Raviart-Thomas shape function on ParaView

Hello everyone, :slight_smile:

I am using RT elements, and I wanted to visualize a single shape function on ParaView, just to check if what I am doing is correct.

I’v learned that I have to interpolate my function on a DG vector function space (and avoid to write directly to VTK file, because of the default CG-1 interpolation).
Since the number of dofs of RT function space is equal to the number of facets (dof = norm of the vector normal to the facet), I am expecting to see a vector centered on a facet.
But when I open my XDMF file on Paraview, I get values on vertices (not on facets center), and I also got redundent points on the same coordinates (nb of points = 3* nb of triangle in 2D), because it didn’t manage points in common between 2 cells.

Here is my following code to export one single RT shape function:

import dolfin as dlf
import numpy as np

mesh = dlf.RectangleMesh(dlf.Point(0.0, 0.0),
                          dlf.Point(0.03 , 0.03),
                          10,
                          10,
                          "left")

V = dlf.FunctionSpace(mesh, "RT", 1)
f = dlf.Function(V)

ndofs = V.dim()
dofmap = V.dofmap()

j = np.zeros(ndofs)

dof = 15 # for example
j[dof] = 1
f.vector().set_local(j)

Vv = dlf.VectorFunctionSpace(mesh, "DG", degree=1, dim=2)
fv = dlf.interpolate(f, Vv)

encoding = dlf.XDMFFile.Encoding.ASCII
with dlf.XDMFFile("out.xdmf") as outfile:
    outfile.write(mesh)
    outfile.write_checkpoint(fv, "current", 0, append=True, encoding=encoding)

And the visualization on Paraview of the output XMDF file
shape_function_norm

Am I missing something ?

Thank you !

You Need to consider the fact that RT 1 is a subset of discontinuous piecewise linear functions: https://defelement.com/elements/examples/triangle-raviart-thomas-1.html
Thus if you interpolate it into DG 1, you will get functions that are contiguous in normal direction over facets, but discontinuous in the tangential direction.

When you interpolate into another space, the original function (in RT) is evaluated at the interpolation points of the output space (in your case at every vertex of the cell).
If you interpolate into DG 2, you would have dofs on the center of all facets (and They would be duplicated for every cell to encapsulate the tangential discontinuity across elements.