Division by zero error when plotting a gradient


75
views
0
3 months ago by
What I want to do is plot `\gradient\lnorm\nabla u\rnorm_2^2`, where `u` is the solution to my PDE:

solve(a == L, u, bc)
v = dot(grad(u), grad(u))
plot(grad(v))

When I run this code, I get:

/usr/lib/python2.7/dist-packages/matplotlib/quiver.py:645: RuntimeWarning: divide by zero encountered in double_scalars
  length = a * (widthu_per_lenu / (self.scale * self.width))
/usr/lib/python2.7/dist-packages/matplotlib/quiver.py:645: RuntimeWarning: invalid value encountered in multiply
  length = a * (widthu_per_lenu / (self.scale * self.width))

The problem is with plotting, and not computing the gradient. Just calling grad(u) on its own causes no error.
Community: FEniCS Project
Please login to add an answer/comment or follow this question.

Similar posts:
Search »