The subregion method in magnetic field analysis and design optimization