A thermodynamical theory of turbulence. I. Basic developments