Moving refine_smooth into mesh for both cpu and gpu versions