[overture] Re: Indexing Problem

  • From: Bill Henshaw <henshaw@xxxxxxxx>
  • To: "overture@xxxxxxxxxxxxx" <overture@xxxxxxxxxxxxx>
  • Date: Fri, 23 Dec 2011 09:48:37 -0800

Hi Mostafa:
 The syntax you show below is strange, you should use something like:
     mg.vertex()(100,100,100,5)
This will cause an error like the one below when you add
#define BOUNDS_CHECK
to the top of your C++ file. ...Bill

ERROR: Scalar Index for dimension(0) = 100 out of bounds!
*********************************************************
Scalar values used in indexing:
    Scalar Index (along dimension 0) = 100
    Scalar Index (along dimension 1) = 100
    Scalar Index (along dimension 2) = 100
    Scalar Index (along dimension 3) = 5
****************************************************************
Original Array object base and Bounds are:
    (Base[0] = -1,Bound[0] = 11)
    (Base[1] = -1,Bound[1] = 11)
    (Base[2] = 0,Bound[2] = 0)
    (Base[3] = 0,Bound[3] = 1)
    (Base[4] = 0,Bound[4] = 0)
    (Base[5] = 0,Bound[5] = 0)
****************************************************************

mostafa amini afshar wrote:
Hi Bill

Thanks for the reply.

I have added the #define BOUNDS_CHECK directive to my file, but when I try to get the coordinate for a point beyond the index bound using the vertex function like " mg.vertex(I1,I2,I3,axis2)(1,300,3) " , the program still gives a value and dose not complain. Could you please kindly tell me what is the problem?

Best regards
Mostafa

------------------------------------------------------------------------
*From:* Bill Henshaw <henshaw@xxxxxxxx>
*To:* "overture@xxxxxxxxxxxxx" <overture@xxxxxxxxxxxxx>
*Sent:* Tuesday, 20 December 2011, 1:17
*Subject:* [overture] Re: Indexing Problem

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 everyone

I 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))
                                             {
                                                    .....................






Other related posts: