Ampère's Law for an infinitely long straight wire In order to find the magnetic field generate by an infinitely long straight wire of radius R, I have to use local Ampère's Law :
$\boxed{ \oint_L B\cdot dl = \mu_0 \sum_j I_j}$
If $r > R$ then $ \oint_L B\cdot dl = B(r)\cdot 2\pi r = \mu_0 I \Rightarrow  B(r) = \dfrac{\mu_0 I}{2\pi r} $
(I'm okay with this expression)
But if $r<R $ I'm supposed to find $ \oint_L B\cdot dl = B(r)\cdot 2\pi r = \mu_0 I \cdot \dfrac{\pi r^2}{\pi R^2} \Rightarrow  B(r) = \dfrac{\mu_0 I r}{2\pi R^2} $
I don't understand where come from the $\dfrac{\pi r^2}{\pi R^2}$ factor.
Thanks for your help (and sorry for my bad english)
 A: This is perfectly analogous to applying Gauss' Law for a solid ball of volume charge density $\rho$ and solving for the E-Field within the ball, $r < R$.
These factors come into play because the $I$ in the RHS of Ampere's Law is understood mean the total current enclosed by your Amperian loop.
Now if you are solving for the magnetic field within a current carrying cylinder of radius $R$ you need to solve for the current enclosed by your Amperian loop of radius $r$.
You can do this by realizing that ratio of the area of your amperian loop to that of the full cross sectional area of the current carrying cylinder gives the ratio of how much current enclosed there will be.
$$I_{enclosed} = \frac{\pi r^2}{\pi R^2}I$$
As a simple check notice that when $r=R$, you get the total current, as expected. With this in the RHS of Ampere's Law and the path integral of the magnetic field around the Amperian loop being $2\pi r B$ you get your result.
edit: Maybe my reasoning by inspection isn't that obvious in giving the current enclosed. To make it more rigorous it is helpful to consider the current density $J = I/A$ which is the current divided by its cross sectional area, in this case a circle of radius $R$. Given any current density you can get the enclosed current enclosed by a path by simply multiplying it with the area. Such that $I_{enclosed} = JA_{Amperian Loop}$.
