Projection of DG0 Function over Non-Matching Meshes

I am not sure why you would expect anything else than what is shown when executing your code:


DG-0 means that each cell has a degree of freedom associated with its midpoint.

In the plot above we can see the initial mesh, with 3 elements, whose value is constant within each sub interval.
We also see the “new” mesh with 4 elements (denoted by the interval between the nodes).
As the degrees of freedom is associated with each midpoint, the old function is evaluated at these, giving rise to the plot below


which is logically in this way as the midpoint of the two cells in the middle both fall inside the “light-blue/green” area.

If you want something smoother, you can use an L2 projection as sketched out in L2 projection of fine mesh solution to a coarse mesh - #6 by dokken
However, you will encouter gibbs phenomenon, as discussed in
Projection and interpolation — FEniCS Tutorial @ Sorbonne

1 Like