The development of residual stress in cooling rock bodies