Solution (source code)

= Solution

Put $r^2=x^2+y^2$. On the specified domain, $r>0$, and direct differentiation gives the <divergence> and <vorticity>
$$
\nabla\cdot\mathbf u=U'(z),\qquad \nabla\times\mathbf u=\mathbf0.
$$
For example, the third component of the <curl> is $A(r^2-2x^2)/r^4+A(r^2-2y^2)/r^4=0$; the other two components vanish because $U$ depends only on $z$ and the transverse velocity is independent of $z$. Hence \b[the flow is both incompressible and irrotational exactly when]
$$
\boxed{U(z)=U_0\text{ is constant},\qquad A\text{ is arbitrary}.}
$$
The exclusion of the axis matters: these are ordinary derivatives on the domain, with no assertion of regularity on the removed axis.