Gradient of a tensor in variational form

9 months ago by
Hi all,

I'm having trouble computing the gradient of a tensor in the variational form.

  $\frac{d}{dx_j}S_{ij}$ddxj Sij

where Sij is the strain rate tensor .
def Sij(u):
    return 0.5*(nabla_grad(u)+transpose(nabla_grad(u)))

V = VectorFunctionSpace(mesh,'CG',1,dim=3)

u = TrialFunction(V)
v = TestFunction(V)
u_n = Function(V)
u = Function(V)

a1 = dot(u,v)*dx
L1 = dot(u_n,v)*dx + dot(nabla_grad(Sij(u_n)),v)*dx)

solve(a1 == L1, u)

This is a shortened version of my variational form but this is my error

ufl.log.UFLException: Can only integrate scalar expressions. The integrand is a tensor expression with value shape (3, 3) and free indices with labels ().
Community: FEniCS Project

1 Answer

9 months ago by

the second summand in your bilinear Form L1 translates to

$\int\frac{\partial S_{ij}}{\partial x_k}v_k\mathrm{d}x$Sijxk vkdx 

or symbollically

$\int\left(S\otimes\nabla\right)\cdot v\mathrm{d}x$(S)·vdx

and thus is a tensorial expression (two free indices). Every integral expression has to be scalar in any case.
What you want to achieve, i.e.

  $\int\frac{\partial S_{ji}}{\partial x_i}v_j\mathrm{d}x$Sjixi vjdx

is the dot product of the divergence of Sij and v. You can this write as

But be careful. If Sij comes from a piecewise constant function space this won't work. Consider integration by parts.

I dont need it in a scalar form, u and v are functions from a VectorFunctionSpace of dimension 3. Basically, I'm trying to add that term to the Navier Stokes equations and dot it just like the rest of the momentum equations

[ S11 S12 S13; S21 S22 S23; S31 S32 S33]
grad = [d/dx d/dy d/dz]

----> [ d/dx(S11) + d/dy(S12) + d/dz(S13) ;  d/dx(S21) + d/dy(S22) + d/dz(S23); d/dx(S31) + d/dy(S32) + d/dz(S33) ]
This is what I'm trying to achieve since I'm assuming there's an implicit summation

written 9 months ago by Luz Imelda Pacheco  
What you wrote is the divergence of the tensor S, which is a vector. The expression you gave is $\frac{\partial S_{ij}}{\partial x_j}$Sijxj which has one free index. The dot product with your test function v would then yield a scalar expression you can integrate. Just your implementation is wrong, since nabla_grad gives  $\frac{\partial S_{ij}}{\partial x_k}$Sijxk   and is a tensor of rank three.
You'll want to write
written 9 months ago by klunkean  
I see it now, sorry! Thank you for your help!
written 9 months ago by Luz Imelda Pacheco  
No need to be sorry! Glad I could help :)

Oh and symbolically you can also write
written 9 months ago by klunkean  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »