Not a complete solution, but perhaps these snippets can help you.
Note the definition of UF3.
You have to compute $\frac{\partial \underline{u}}{\partial z}$ by hand and use it as the "up" argument of functions grad3d, epsilon and sigma. You'll also need to change the definition of the epsilon function if what you need is the Green-Lagrangian strain tensor.
def grad3d(u, up):
"Return 3d gradient."
g = grad(u)
return as_tensor([[g[0,0], g[0,1], up[0]],[g[1,0], g[1,1], up[1]],[g[2,0], g[2,1], up[2]]])
def epsilon(u, up):
"Return symmetric 3D deformation tensor."
return 0.5*(grad3d(u, up).T + grad3d(u, up)) #
def pos3d(POS):
return as_vector([POS[0], POS[1], 0.])
def sigma(u, up):
"Return stress tensor."
eps = epsilon(u, up)
return 2.0*mu*eps + lmbda*tr(eps)*Identity(3)
mesh = UnitSquareMesh(10, 10) #2D mesh
UF3 = VectorFunctionSpace(mesh, "CG", 2, 3)