Design of thermoelastic materials using direct sensitivity and optimization methods. Reduction of thermal stresses in functionally gradient materials