Computation and visualization of magnetic fields