Added gradient function for staggered grid, rearranged reading in divergence func