This seems like a silly question, but I can't seem to get the array values from the divergence of a vector. Here's essentially what I'm trying to do:
V = VectorFunctionSpace(mesh, "CG", 2, dim=3)
Q = FunctionSpace(mesh, "CG", 1)
W = V*Q
w = Function(W)
true_solution = Expression(('cos(pi*x[2])','sin(pi*x[0])','cos(pi*x[1])'),t=0.0)
(u,p) = w.split(0)
u.assign(true_solution)
p.assign(nabla_div(u)) #this is the important line
which, obviously results in an error because nabla_div doesn't produce that kind of object.
There simply must be an easy way to do this. Suggestions? (Thanks again!)