# [Gmsh] 3D array

**Christophe Geuzaine**
christophe.geuzaine at case.edu

*Mon Apr 17 18:03:17 CEST 2006*

Ingo Reinhold wrote:
>* Oh, I thought the manual is talking about sublists at some stage, which
*>* would then enbale the solution of my problem.
*
I would just do it like this:
lc=1;
//dimensions
xdim=5;
ydim=5;
zdim=5;
//random distribution
For i In {0:xdim-1}
For j In {0:ydim-1}
For k In {0:zdim-1}
array[i*ydim*zdim + j*zdim + k] = Fmod(Rand(1), 1);
EndFor
EndFor
EndFor
//check
For i In {0:xdim-1}
For j In {0:ydim-1}
For k In {0:zdim-1}
Printf("array[%g][%g][%g] = %g", i, j, k,
array[i*ydim*zdim + j*zdim + k]);
EndFor
EndFor
EndFor
>*
*>* Regards,
*>*
*>* Ingo
*>*
*>*
*>* On Apr 15, 2006, at 8:56 PM, Christophe Geuzaine wrote:
*>*
*>>* Ingo Reinhold wrote:
*>>>* Dear all,
*>>>* I am pretty new to GMSH and I tried to initialize a 3D array and
*>>>* fill it with random numbers.
*>>>* lc=1;
*>>>* //dimensions
*>>>* xdim=5;
*>>>* ydim=5;
*>>>* zdim=5;
*>>>* array[{xdim,ydim,zdim}]=1;
*>>*
*>>* Ingo - Gmsh only supports 1D arrays...
*>>*
*>>*
*>>>* //random distribution
*>>>* For i In {0:(xdim-1):1}
*>>>* For j In {0:(ydim-1):1}
*>>>* For k In {0:(zdim-1):1}
*>>>* array[{i,j,k}]=0;
*>>>* array[{i,j,k}]=Fmod (Rand (1),1);
*>>>* EndFor
*>>>* EndFor
*>>>* EndFor
*>>>* For some reason i can not write or acces the array. It also tells me
*>>>* that the number of imbricated loops is reached. Does that mean I
*>>>* can't interleave more that 3 loops?
*>>>* Thanks for helping,
*>>>* Ingo
*>>>* _______________________________________________
*>>>* gmsh mailing list
*>>>* gmsh at geuz.org
*>>>* http://www.geuz.org/mailman/listinfo/gmsh
*>>*
*>>*
*>>* --Christophe Geuzaine
*>>* Assistant Professor, Case Western Reserve University, Mathematics
*>>* http://www.case.edu/artsci/math/geuzaine
*>>*
*>*
*>*
*
--
Christophe Geuzaine
Assistant Professor, Case Western Reserve University, Mathematics
http://www.case.edu/artsci/math/geuzaine