The square at row $r$ and column $c$ has indices:
\[\begin{array}{l} i_0 = (r+0) \cdot n+ (c+0) \\ i_1 = (r+1) \cdot n+ (c+0) \\ i_2 = (r+0) \cdot n+ (c+1) \\ i_3 = (r+1) \cdot n+ (c+1) \\ \end{array}\]And the triangulation of that square is:
\[[i_0, i_1, i_2] \\ [i_2, i_1, i_3]\]