Grating with strain-induced spatially varying refractive index