My current problem involves the Laplace operator of a known function f
in the weak formulation. Since $\Delta f = \nabla \cdot \nabla f$, I figured I could just use div(grad(f))
here. However, this returns a function that is zero everywhere?
As the code below shows, I also tried applying the second derivatives directly. Am I correct to believe that f.dx(0).dx(0)
is UFL for $\frac{\partial^2 f}{\partial x^2}$?
from dolfin import *
mesh = UnitCubeMesh(30, 30, 30)
V = FunctionSpace(mesh, 'CG', 1)
expr = Expression('x[0]*x[0]*x[0] - x[1]*x[1]*x[2]')
f = project(expr, V)
plot(f, interactive=True)
plot(grad(f), interactive=True)
plot(div(grad(f)), interactive=True)
plot(f.dx(0).dx(0) + f.dx(1).dx(1) + f.dx(2).dx(2), interactive=True)
ps I am currently using version 1.4