A nodal analysis approach for 2D and 3D magnetic-circuit coupled problems