Projecting Stress Tensor on radial coordinate

I have a stress function on an annular domain centered at the origin. Is there an easy way I can project this onto the radial direction, eg.

\sigma_{rr} = \frac{r^T \sigma r}{r^T r}

from the mesh itself?

You could try something like the following,

r = SpatialCoordinate(mesh)
sigma_rr = dot(r,sigma(u)*r)/dot(r,r)

where sigma is a Python function that returns the stress as a UFL tensor given a displacement field u. sigma_rr could then be used in a formulation or projected to a finite element space for visualization.

Thank you, this worked perfectly!