Is there a diff operator for partial derivatives

Hi,
I’m a little new to NGSolve and was looking for an operator for a simple partial derivative to solve a problem with a Bilinear form that might look like this:

[tex]\int_\Omega\frac{\partial v(x,y)}{\partial x}\frac{\partial u(x,y)}{\partial x}\mathrm{d}x\mathrm{d}y[/tex]

I found that coefficient functions have a partial derivative method called diff(), I was hoping there would be somthing similar for test and trial functions that might look something like this:

a = BilinearForm(fes)
a+=(diff(u,x)*diff(v,x))*dx

Does such an function exist in NGSolve (obviously the above doesn’t work)? Sorry if I simply haven’t read the documentation well enough

Hi gflower,

you can get access to the i-th partial derivative by taking the i-th entry of the full gradient.

For a scalar u and v your example would be

a = BilinearForm(fes)
a+= grad(u)[0]*grad(v)[0]*dx

Best,
Michael

Hi mneunteufel,

Thanks for your post. What if u and v are not scalars? In other words, if u is a vector, can we get one component of u first, then take the gradient, then pick the i th component? Thanks in advance!

Hi Subway,

for vector-valued functions you can compute the Jacobian matrix and then choose the j-th partial derivative of the i-th component of the vector. E.g.:

fes = HCurl(mesh, order=2)
u,v = fes.TnT()

a = BilinearForm(fes)
a += Grad(u)[0,1]*Grad(v)[0,1]*dx   #dx_2u_1*dx_2v_1

Using Grad gives always the Jacobian, grad gives, depending on the finite element space, the Jacobian or the transpose of the Jacobian.

Best,
Michael

Hi Michael,

That makes sense. Thanks a lot for your help!