Total current for an arbitrary current density Imagine a localized region $\mathcal{R}$ which contains a current density $\mathbf{j}$, which we take to be divergence-less, $\mathbf{\nabla\cdot j} = 0$. What is the total current associated with this current density?
If $\mathcal{R}$ has the topology of a torus, which is true for filamentary currents, we can calculate the flux of $\mathbf{j}$ over any cross section of the torus and find the total current as a surface integral $$I = \int_\limits \text{cross-section} \mathbf{j} \cdot d\mathbf{S}.$$ We see that the total current is a measure of a "total number of integral curves" of a transverse vector field $\mathbf{j}$.
My question: is it possible to generalize the notion of total current for an arbitrary current density localized to a region which doesn't have the topology of a torus? A simple example would be a rotating charged sphere.
I think that, mathematically, I am looking for a invariant of a localized, transverse vector field $\mathbf{j}$ which "counts" the number of distinct integral curves of such a field. So, answers from differential geometry are also welcome.
 A: If we start from the charge-current continuity equation for any arbitrary charge distribution, we have:
$$
\partial_{t} \rho + \nabla \cdot \mathbf{j} = 0 \tag{0}
$$
where $\rho$ is the charge density, $\mathbf{j}$ is the current density (specifically the macroscopic average current density, see pages 248--258 in Jackson [1999] for definition and derivation), and $\partial_{t} = \tfrac{ \partial }{ \partial t }$.  In the absence of charge density changes, i.e., steady state, the first term on the left-hand side of Equation 0 goes to zero and we have $\nabla \cdot \mathbf{j} = 0$.  The continuity equation shown in Equation 0 is just mathematical speak saying if there is any change in charge within some volume, $V$, it must correspond to a flow of charge (i.e., a current) in or out through the surface, $S$, of that volume.
We can integrate over the volume to find the total current enclosed, $I_{enc}$, given by:
$$
I_{enc} = \int \ dV \ \nabla \cdot \mathbf{j} = \int_{S} dA \ \mathbf{n} \cdot \mathbf{j} \tag{1}
$$
where $\mathbf{n}$ is an outward unit normal vector with respect to the surface $S$.  If we assume a static scenario where $\partial_{t} \mathbf{E} = 0$ (i.e., no time-variation of the electric field), then we can use Ampere's law from Maxwell's equations to show that:
$$
\int_{S} dA \ \mathbf{n} \cdot \mathbf{j} = \frac{ 1 }{ \mu_{o} } \int_{S} dA \ \mathbf{n} \cdot \left( \nabla \times \mathbf{B} \right) = \frac{ 1 }{ \mu_{o} } \oint_{C} \ d\mathbf{l} \cdot \mathbf{B} = I_{enc} \tag{2}
$$
where $\mathbf{B}$ is the magnetic field, $d\mathbf{l}$ is a unit path length along closed contour $C$, and $\mu_{o}$ is the permeability of free space.  In principle, one could do this for a material with a finite permeability beyond that of the free space limit.  In this case, $\mathbf{B} \rightarrow \mu \ \mathbf{H}$ so that the factor in front of the contour integral is just the ratio of the material permeability to that of free space (assuming $\mu$ is uniform throughout the volume of interest).

My question: is it possible to generalize the notion of total current for an arbitrary current density localized to a region which doesn't have the topology of a torus?

The above equations are general for any geometry in real space.  That is, $V$ can be any arbitrary volume, $S$ can the surface of this arbitrary volumen, and $C$ is only constrained in that it must lie on the surface $S$.

I think that, mathematically, I am looking for a invariant of a localized, transverse vector field $\mathbf{j}$ which "counts" the number of distinct integral curves of such a field. So, answers from differential geometry are also welcome.

Unless the current density $\mathbf{j}$ is non-uniform throughout the volume, the above equations will be general, since $\mathbf{j}$ is just the current per unit area.  That is, one need not sum up a semi-infinite number of $I_{enc}$ values from Equations 1 and 2 to get a total current.  If the current is not uniform in the volume, then the $\partial_{t} \rho$ term will be finite in some places within the volume and thus break the requirement that $\nabla \cdot \mathbf{j} = 0$.

What is the total current associated with this current density?

So long as $\mathbf{j}$ is uniform throughout the volume, Equation 1 or 2 above will give you the enclosed current, which is the total current (e.g.,, see pages 178--180 in Jackson [1999]).  Of course, if the user chooses a bad contour $C$ that is not actually on the surface or not closed, the result will be incorrect.
References

*

*J.D. Jackson, Classical Electrodynamics, Third Edition, John Wiley & Sons, Inc., New York, NY, 1999.

