we use Ampere's circuital law to calculate or determine the magnetic field which is produced by the associated current. The condition is only that current should be enclosed by the loop. (only the Ampere's law will apply). If the current is flow
Read this post on apniphysics.com