### How to save deformation gradient tensor

194

views

0

Hi there i am solving a nonlinear elasticity problem in which i compute deformation gradient before specifying the weak form as under

```
# kinematics
d = u.geometric_dimension()
I = Identity(d)
F = I + grad(u)
C = F.T*F
B = F*F.T
J = det(F)
.
.
.
.
.
eq = inner(P,grad(du))*dx + inner(J-1,dp)*dx
Jac = derivative(eq, up)
.
.
solve(eq==0,up,bcs,J=Jac)
```

I want to print or save the deformation gradient tensor (F) during solving this problem. I tried to save it as an array but that results in error. Can anyone suggest how to save the deformation gradient tensor to a file. Also if i want to print or use a particular component of the deformation gradient tensor then how to go about that ?

Thanks

Community: FEniCS Project

### 1 Answer

1

You could project onto a suitable function space, i.e.

```
TFE = TensorElement(u.ufl_element().sub_elements()[0], shape = (d,d))
TensorSpace = FunctionSpace(mesh, TFE)
F_proj = project(F, TensorSpace)
# Save to File
File('defgrad.pvd') << F_proj
```

Thanks! i am trying this code.

written
6 months ago by
Ovais

Please login to add an answer/comment or follow this question.