Hello,
While trying to figure out how to write a partial derivative $\partial_x u$, I wrote the following piece of code to solve $-\partial_x^2 u(x,y)=-x-y^2$ in 2D with boundary conditions $u_0 = \tfrac{x^3}{6}+\tfrac{x^2y^2}{2}$:
V = FunctionSpace(mesh, 'Lagrange', 2)
#a = inner(nabla_grad(u)[0], nabla_grad(v)[0])*dx
a = inner(u.dx(0), v.dx(0))*dx
L = f*v*dx
Here are the questions:
1) do both forms nabla_grad(u)[0]
and u.dx(0)
represent the partial derivative in the x direction? Is there any difference between the two?
2) I have noticed that the difference between the numerical and the exact solution $u_0$ is largest (of order $10^{-5}$ relative) at the boundaries, which is puzzling because the boundaries are imposed. What is the reason for this?