Three dimensional stability analysis of high-temperature superconductors using the finite element method