I'm considering the following quesion about Poisson equation:
$$ -\Delta u=f $$ in a ball radius $1$ in $3$ dimension, if $f\in L^{2}$, then the theory of elliptic PDE says that the above equation exists unique solution $u\in H_{0}^{1}$. Then I suppose that $f=r-1$, where $r=\sqrt{x^{2}+y^{2}+z^{2}}$, this is a radial function, so we can suppose that the solution $u$ must be a radial function, i.e. $u\left(x\right)=u\left(r\right)$, then I considered $$ u''\left(r\right)+\frac{n-1}{r}u'\left(r\right)=1-r. $$ The solution of this ODE with boundary condition $u\left(1\right)=0$ and $u'\left(1\right)=0$ added is $$ u\left(r\right)=-\frac{\left(r+1\right)\left(r-1\right)^{3}}{12r}. $$ It is true that $u\left(r\right)$ is a solution of the Poisson equation, but by calculating $$ \nabla u=u'\left(r\right)\cdot\frac{x}{r}=\frac{-1+\left(4-3r\right)r^{3}}{12r^{2}}\cdot\frac{x}{r} $$ and $\left|\nabla u\right|=\frac{1-\left(4-3r\right)r^{3}}{12r^{2}}$, but $\|\nabla u\|_{L^{2}}=\infty$, this contradicts $u\in H_{0}^{1}$. what am I get wrong in somewhere?
The problem is coming from your enforcement of the second boundary condition $u'(1)=0$, which is not something that must be true. The general solution of the ODE with the BC $u(1) =0$ is $$ u(r) = C\left(1 - \frac{1}{r}\right) - \frac{1}{12} + \frac{r^2}{6} -\frac{r^3}{12}. $$ for some constant $C$. If you enforce the condition $u'(1)=0$ then you get a nontrivial $C$, which is causing the problems with the gradient. If instead you pick $C$ to enforce the gradient condition then you'll get $C=0$, which kills the singular term at the origin. Roughly speaking, what's going on here is that the second boundary condition is at $r=0$ and enforces the condition that your solution is not too singular.