Circulation of a flow along a closed curve enclosing the $z$-axis This is a problem we looked at it class the solution to which I still don't completely understand.
We were asked to find the circulation along any closed curve $\Gamma$ enclosing the $z$-axis of the flow
$u = \big( -\frac{Ay}{x^2+y^2}, \frac{Ax}{x^2+y^2}, B\big)$, where $B$ is some constant and $u$ is defined on $\mathcal{D} = \mathbb{R}^3 - \{z$ axis$\}$.
The answer should be
$C = \int_{\Gamma} u \cdot dl = 2\pi A$.
Now if $u$ is the gradient of some scalar function $f$, i.e. $u = \nabla f$, by inspection we have
$f = A\tan^{-1} (\frac{y}{x}) + Bz$
So if $\mathbb{R}^3$ excluding the $z$-axis were a connected region, then we'd have that $C = 0$. But it's not a connected region, and I'm not sure how one gets to $2\pi A$ - I'd appreciate a detailed explanation.
 A: The velocity field is
$$\mathbf{u} = \frac{-Ay}{x^2+y^2}\mathbf{e}_x+ \frac{Ax}{x^2+y^2}\mathbf{e}_y+ B\mathbf{e}_z$$
Using cylindrical coordinates $(r,\theta,z)$  where  $x = r \cos \theta$, $y = r \sin \theta$, unit basis vectors are related by
$$\mathbf{e_x} = \cos \theta \,\mathbf{e}_r - \sin \theta \, \mathbf{e}_\theta, \quad \mathbf{e_y} = \sin \theta \,\mathbf{e}_r + \cos \theta \, \mathbf{e}_\theta,$$
and the velocity is given by
$$\mathbf{u} = \frac{-Ar \sin \theta}{r^2}\left(\cos \theta \,\mathbf{e}_r - \sin \theta \, \mathbf{e}_\theta \right) + \frac{A r \cos \theta}{r^2} (\sin \theta \,\mathbf{e}_r + \cos \theta \, \mathbf{e}_\theta)+ B\mathbf{e}_z \\ = 0 \cdot \mathbf{e}_r + \frac{A}{r} \mathbf{e}_\theta + B \mathbf{e}_z$$
Consider a general closed curve $\Gamma$ encircling the z-axis with a parametric representation
$$(x,y,z) = \left(f(\theta) \cos \theta,  f(\theta) \sin \theta, g(\theta)\right), \quad 0 \leqslant \theta \leqslant 2 \pi,$$
where $f(0) = f(2\pi)$ and $g(0) = g(2 \pi)$.
The unit tangent vector at a point on $\Gamma$ is
$$\mathbf{t} = (f'(\theta)\cos \theta - f(\theta) \sin \theta) \mathbf{e}_x +  (f'(\theta)\sin \theta + f(\theta) \cos \theta) \mathbf{e}_y + g'(\theta) \mathbf{e}_z \\ = f'(\theta) \mathbf{e}_r + f(\theta) \mathbf{e}_\theta + g'(\theta) \mathbf{e}_z$$
Since $u_r = 0$ and $r = f(\theta)$ on $\Gamma$, the line integral is
$$\int_\Gamma \mathbf{u} \cdot  \mathbf{dl} = \int_0^{2 \pi}0 \cdot f'(\theta) \, d \theta + \int_0^{2 \pi} \frac{A}{f(\theta)} \cdot f(\theta) \, d \theta + \int_0^{2\pi} B \cdot g'(\theta) \, d\theta \\ = 0 + 2\pi A + B(g(2\pi) - g(0)) = 2 \pi A$$

The velocity field is irrotational with $\nabla \times \mathbf{u} = 0$ at all points in $\mathcal{D}$.  However, due to the singularity at points where $x= y = 0$, the requirements for Stokes' theorem are not met. Hence, we cannot conclude for a surface $S$ with $\Gamma$ as the boundary that we have
$$\int_\Gamma \mathbf{u} \cdot \mathbf{dl} = \int_S (\nabla \times \mathbf{u}) \cdot \mathbf{n} \, dS = 0$$
