Effects of surface roughness and patches on the work function of cobalt