Ampere's law

For any open surface $S$ with the boundary $C = \partial S$ a closed curve, (M4') and Stokes' theorem implies $$ \begin{align*} \oint_{C} \v B\cdot \d \v x = μ_0 I \end{align*} $$ where $I = \int_{S} \v J\cdot \d \v S$ is the total current through $S$. The sign convention follows the right-hand rule.

Since $∇\cdot \v J = 0$, $I$ is the same through any open surface $S$ with the same boundary $C$.

By $∇\times \v B = μ_0 \v J$, cylindrically symmetric situation could involve a combination of (in cylindrical polars)

Magnetic field due to long straight wire open_in_new

For a long cylindrical wire of radius $R$ carrying a total current $I$ parallel to its axis, the magnetic field outside $r>R$ is $$ \begin{align*} \v B = \frac{μ_0 I}{2πr} \v e_ϕ. \end{align*} $$ (Derivation)

Magnetic field due to solenoid open_in_new

A solenoid is a thin wire coiled around a cylindrical tube of radius $R$. An ideal solenoid is infinitely long and tightly wound, having cylindrical symmetry and purely azimuthal current.

It produces a magnetic field of $$ \begin{align*} \v B ={}& \begin{cases} \v 0, &r>R, \\ μ_0 IN, &r<R \end{cases} \end{align*} $$ where $N$ is the number of turns per unit length and $I$ is the current.

(Derivation)

At the end of a long solenoid, field is halved: consider joining two ends together.