[Gmsh] behavior of doubly nested loop ?

Oswald Benedikt Benedikt.Oswald at psi.ch
Thu Feb 7 17:39:53 CET 2013


Dear gmsh, the following doubly nested loops gives me results that I do not understand,
i.e. the index should count through from 0 to 19, without giving certain indices twice.

I use the most recent nightly build of gmsh (2.6.2-svn)

Perhaps, I do not see the forest for the trees, can you comment ?

Thanks,Benedikt


numnpx = 4;
numnpy = 3;

/** loop over y period **/
For uy In {0:numnpy}

  /** lop over x period **/
  For ux In {0:numnpx}

    index = uy * numnpx + ux;


    /** compute index of redpoint id in 1-dimensional array **/
    Printf("index - ux, uy, index = [ %g, %g, %g ]", ux,uy,index);

  EndFor
  /** close loop over y coordinates **/

EndFor
/** close loop over x coordinates **/



>From gmsh:

index - ux, uy, index = [ 0, 0, 0 ]
index - ux, uy, index = [ 1, 0, 1 ]
index - ux, uy, index = [ 2, 0, 2 ]
index - ux, uy, index = [ 3, 0, 3 ]
index - ux, uy, index = [ 4, 0, 4 ]
index - ux, uy, index = [ 0, 1, 4 ]
index - ux, uy, index = [ 1, 1, 5 ]
index - ux, uy, index = [ 2, 1, 6 ]
index - ux, uy, index = [ 3, 1, 7 ]
index - ux, uy, index = [ 4, 1, 8 ]
index - ux, uy, index = [ 0, 2, 8 ]
index - ux, uy, index = [ 1, 2, 9 ]
index - ux, uy, index = [ 2, 2, 10 ]
index - ux, uy, index = [ 3, 2, 11 ]
index - ux, uy, index = [ 4, 2, 12 ]
index - ux, uy, index = [ 0, 3, 12 ]
index - ux, uy, index = [ 1, 3, 13 ]
index - ux, uy, index = [ 2, 3, 14 ]
index - ux, uy, index = [ 3, 3, 15 ]
index - ux, uy, index = [ 4, 3, 16 ]