What is thermodynamics and how does it apply to mechanical engineering?

What is thermodynamics and how does it apply to mechanical engineering?