This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

plot deformation

+1 vote

Hi, I want to plot the deformation map of a 2D elasticity problem.

I tried the following code, but it does not work, last line of code bring following error message : All terms in form must have same rank.

W = TensorFunctionSpace(mesh, "Lagrange", 2)
F = grad(u) + Identity(2)
E = 1/2*( F.T*F-Identity(2))
Ep=project(E,W)

Thank you in advance for your help, and for any references concerning the plot function.

related to an answer for: Plot my Stress Tensor Components
closed with the note: Question was answered !
asked Jan 15, 2015 by Claire L FEniCS User (2,120 points)
closed Jan 16, 2015 by Claire L

This code chunk worked fine for me (assuming that u is a vector). Have you tried using 0.5 instead of 1/2 in E? May be a problem with integer division if using Python version below 3.0.

1 Answer

+1 vote

Yes you're right ! I've added a few lines to save deformation tensor in vtk format and open it with paraview :
file_E = File("deformations.pvd")
file_E << Ep
I wonder why it is saved with 9 components whereas my problem is in 2D (I saved displacement field in a separate file, and it also has 3 components instead of 2) ?

answered Jan 16, 2015 by Claire L FEniCS User (2,120 points)

Hi, 2d vectors and tensors are always padded with zeros to fill in the entire 3d vectors and tensors. See here.

Ok, thanks ! So this is just for the output right ? I was wondering whether I correctly defined vector's dimension in my code...

Yes, it just for the output.

...