How to do calculus with the solution function

Hi,
I am trying to compute some integral. The integrand depends on the function.
The method I used before was the following: (using arrays)

V = VectorFunctionSpace(mesh,'P',2) 
#solve the PDE with u
W=FunctionSpace(mesh,'P',2) 

u_arr=np.array(u.vector())

theta_v_arr=np.arctan2(u_arr[1::2],u_arr[::2])
theta_v_arr=theta_v_arr+2*np.pi*(theta_v_arr<=0)

theta_v=Function(W)
theta_v.vector()[:]=theta_v_arr

It seems to work! But know the function I want to compute depends on u derivatives.
What I am trying to calculate is
\int_{\mathscr{C}}\, \mathrm{d} \theta_{v}=\int_{\mathscr{C}}\, \frac{\partial \theta_{v}}{\partial \phi}\mathrm{d} \phi =\int_{\mathscr{C}}\, -y \frac{\partial \theta_{v}}{\partial x}+x\frac{\partial \theta_{v}}{\partial y}\mathrm{d} \phi

I have a more detail version of this integrand:

theta_prime=((X[0]*u[1].dx(1)-X[1]*u[1].dx(0))*u[0]-(X[0]*u[0].dx(1)-X[1]*u[0].dx(0))*u[1])/(u[0]**2+u[1]**2)

It seems that this is not a Function because when I assemble I get the following error:

DijitsoError: Dijitso JIT compilation failed,

The problem is that since there is derivatives I can’t use .vector…
Is this a problem possible to solve? If you have any ideas I would be thankfull.

1 Like

The solution was quite simple just:

th=dolfin.project(theta_prime)