Astrophysical and Cosmic Thermodynamics