title: Making grid triangular mesh quickly with Numpy
body: <p>Consider a regular matrix that represents nodes numbered as shown in the figure:</p>
  
  <p><a href="https://i.stack.imgur.com/qPJ99m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qPJ99m.png" alt="NodesAndTriangles"></a></p>
  
  <p>I want to make a list with all the triangles represented in the figure. Which would result in the following 2 dimensional list:<code>[[0,1,4],[1,5,4],[1,2,5],[2,6,5],...,[11,15,14]]</code></p>
  
  <p>Assuming that the dimensions of the matrix are (<code>Nr</code>X<code>Nc</code>) ((4X4) in this case), I was able to achieve this result with the following code:</p>
  
  <pre><code>def MakeFaces(Nr,Nc):
      Nfaces=(Nr-1)*(Nc-1)*2
      Faces=np.zeros((Nfaces,3),dtype=np.int32)
      for r in range(Nr-1):
          for c in range(Nc-1):
              fi=(r*(Nc-1)+c)*2
              l1=r*Nc+c
              l2=l1+1
              l3=l1+Nc
              l4=l3+1
              Faces[fi]=[l1,l2,l3]
              Faces[fi+1]=[l2,l4,l3]
      return Faces
  </code></pre>
  
  <p>However, the double loop operations make this approach quite slow. Is there a way of using numpy in a smart way to do this faster?</p>