Analytical and Finite Element Analysis of Thermal Stresses in TiN Coatings