Heat accumulation on coral reefs mitigated by internal waves