You need to use the outer projection for the tangential projection:

```
def tangential_proj(u, n):
return (ufl.Identity(u.ufl_shape[0]) - ufl.outer(n, n)) * u
def sym_grad(u):
return ufl.sym(ufl.grad(u))
def T(u, p):
return 2 * mu * sym_grad(u) - p * ufl.Identity(u.ufl_shape[0])
g_tau = tangential_proj(T(u_ex, p0)*n, n)
```