Method of manufactured solution cylindrical

Thanks for the fix!

Any idea how to perform the same with spherical coordinates?
I have the same issue (in that case the source term is f=-6).

from fenics import *


mesh = IntervalMesh(100, 1e-9, 1)
V = FunctionSpace(mesh, "P", 1)
u = Function(V)
v = TestFunction(V)

uD = interpolate(Expression("1 + x[0]*x[0]", degree=3), V)

bcs = [
    DirichletBC(V, uD, "on_boundary")
]

x = SpatialCoordinate(mesh)
r = x[0]

# spherical diffusive term
F = (r*v.dx(0)-v)*u.dx(0)*dx
# source term
f = Constant(-6)
F += -f*v*dx


solve(F==0, u, bcs)


XDMFFile("computed_solution.xdmf").write(u)
XDMFFile("real_solution.xdmf").write(uD)

error_L2 = errornorm(uD, u, 'L2')
print(error_L2)

EDIT: this variational form was found here