Hi Mostafa:What you have may be ok. Bounds checking on scalar indexing is not turned on by default (as it slows things down). Add #define BOUNDS_CHECK to the top of your
file to turn it on.There are examples in the Overture/primer/gridPrint.C file of how I would loop over grid functions and index them with scalars i,j,k. There is generally no need to
make additional copies as you have done. ...Bill
mostafa amini afshar wrote:
Hi everyoneI am trying to index all elements in 3D mappedgridfunction arrays. Actually the intention is to loop over all elements one by one using i,j and k indexing as follows.I am doubtful if i am correctly indexing the elements as when i set index values larger than the length of the array index, the program still runs!. I would highly appreciate it if anyone can tell me whether I am indexing the elements in a proper way.Best regards Mostafa realArray zco(I1.length(),I2.length(),I3.length()); zco=mg.vertex()(I1,I2,I3,axis2); realArray xco(I1.length(),I2.length(),I3.length()); xco=mg.vertex()(I1,I2,I3,axis1); realArray yco(I1.length(),I2.length(),I3.length()); yco=mg.vertex()(I1,I2,I3,axis3); realArray function(I1.length(),I2.length(),I3.length()); function=fxyz[grid](I1,I2,I3); realArray difference(I1.length(),I2.length(),I3.length()); difference=zco-fxyz[grid](I1,I2,I3); for(int i=12;i<=12;i++) { for(int k=1;k<=1;k++) { for(int j=0;j<=I2.getBound();j++){ if((difference(i,j+1,k)>0 and difference(i,j,k)<0) or (difference(i,j+1,k)<0 and difference(i,j,k)>0)){ .....................