Using ufl for manifactured solutions

The interface to interpolate ufl-expressions is not quite as you tried to use it.

You need to use dolfinx.fem.Expression as a wrapper around the ufl-expression.

This is shown of in various places:
https://jsdokken.com/dolfinx-tutorial/chapter1/membrane_code.html?highlight=fem+expression#interpolation-of-a-ufl-expression
https://jsdokken.com/dolfinx-tutorial/chapter4/convergence.html?highlight=fem+expression#reliable-error-norm-computation
https://jsdokken.com/fenics22-tutorial/heat_eq.html#post-processing-without-projections

1 Like