Simple question about divergence of a vector field


116
views
0
3 months ago by
I am new to FEniCS and I am trying to verify a small portion of my code that is giving me unexpected results. I am trying to verify  $\Delta F=4$ΔF=4 where  $F=x^2+y^2$F=x2+y2 . My simple code snippet is as follows:

cells_per_side = 32
mesh = UnitSquareMesh(cells_per_side,cells_per_side)
V = FunctionSpace(mesh, 'P', 1)
F = project(Expression('x[0]*x[0] + x[1]*x[1]',degree=2), V)
plot_func(div(grad(F))
​


 $F$F  and its gradients seem to compute just fine but I get a function identical to zero for  $\Delta F$ΔF . Is there something obvious that I am missing here?

Community: FEniCS Project
3
Is it because you project degree=2 to FunctionSpace P1, which seems too low in this case?
written 3 months ago by Corwinpro  
1
You might also want to use interpolate(...) instead of project(...), since projection only results in approximate values.
written 3 months ago by Adam Janecka  
Too right, too right.
written 3 months ago by pf4d  

1 Answer


2
3 months ago by
pf4d  
Yes, the 1st derivative of the linear P1 space is constant, and the 2nd derivative is identically zero.  Hence, increase the order to at least P2.
Yeah, that seemed to have been it. How silly of me. Thanks!
written 3 months ago by Sheroze Sheriffdeen  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »