Thermomechanics of two contacting bodies