uniform mesh generation code