```
import numpy as np
from mpi4py import MPI
import ufl
from dolfinx import fem, mesh
import dolfinx.fem.petsc
L = 120.0
W = 4.0
H = 8.0
Nx = 20
Ny = 5
Nz = 10
domain = mesh.create_box(
MPI.COMM_WORLD,
[(0.0, 0.0, 0.0), (L, W, H)],
(Nx, Ny, Nz),
cell_type=mesh.CellType.hexahedron
)
E = fem.Constant(domain, 2000000.0)
nu = fem.Constant(domain, 0.3)
mu = E / 2 / (1 + nu)
lmbda = E * nu / (1 + nu) / (1 - 2 * nu)
def eps(v):
return ufl.sym(ufl.grad(v))
def sigma(v):
return lmbda * ufl.tr(eps(v)) * ufl.Identity(3) + 2.0 * mu * eps(v)
fx = 0.1
fy = -1.0
f = fem.Constant(domain, (fx, fy))
V = fem.functionspace(domain, ("Lagrange", 1))
du = ufl.TrialFunction(V)
u_ = ufl.TestFunction(V)
a = ufl.inner(sigma(du), eps(u_)) * ufl.dx
l = ufl.inner(f, u_) * ufl.dx
```

I modified the code from the computing reactions example where a 2D cantilever beam is set up and changed things over to a box because I would like to experiment a bit with how to take moment from a 3D mesh.

This code also was modified in the hopes to create a stress tensor that can work with the 3D box:

```
def sigma(v):
return lmbda * ufl.tr(eps(v)) * ufl.Identity(3) + 2.0 * mu * eps(v)
```

So there seems to be a difficulty creating the bilinear form a…

```
Traceback (most recent call last):
File "/home/prusso/dolfinx-demos/Untitled-1", line 40, in <module>
a = ufl.inner(sigma(du), eps(u_)) * ufl.dx
^^^^^^^^^
File "/home/prusso/dolfinx-demos/Untitled-1", line 31, in sigma
return lmbda * ufl.tr(eps(v)) * ufl.Identity(3) + 2.0 * mu * eps(v)
^^^^^^
File "/home/prusso/dolfinx-demos/Untitled-1", line 27, in eps
return ufl.sym(ufl.grad(v))
^^^^^^^^^^^^^^^^^^^^
File "/home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/python3.11/site-packages/ufl/operators.py", line 337, in sym
return Sym(A)
^^^^^^
File "/home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/python3.11/site-packages/ufl/tensoralgebra.py", line 542, in __new__
raise ValueError("Symmetric part of tensor with rank != 2 is undefined.")
ValueError: Symmetric part of tensor with rank != 2 is undefined.
```

I don’t really know what it means at this point. How should the code be set up in terms of finding the post processed stress for in terms of moment or Mz for the box?