changed grid to 1D, xyto1D maps cartesian [1,N][1,N] to index [0,N^2-1]