Application of Finite Elements in Computing Permanent Magnet Fields