Project(x) works, interpolate(x) does not

Only selected objects like Functions, Expressions, and UserExpressions can be interpolated using interpolate. The project function uses L^2 projection, which is oscillatory when projecting a discontinuous function onto a continuous space. Some options for monotone projection would be to project to a discontinuous Galerkin space (e.g., FunctionSpace(mesh,"DG",0) for element-wise constants), or to use a lumped-mass projection, which can be implemented a few ways, as demonstrated in this post or this tutorial.

2 Likes