[petsc-users] Global DA index using DAGetCorners

Barry Smith bsmith at mcs.anl.gov
Thu Nov 25 20:31:17 CST 2010


On Nov 25, 2010, at 7:50 PM, khalid ashraf wrote:

> It doesn't seem like the problem is with the natural ordering. Since in Fig.9 of the manual,
> the highest number of the grid should be the same(30 in fig. 9) for natural and petsc ordering.
> But I get a lower number when I print it. 
> 
> I also tried the petsc to natural conversion using the following code,   
>    {
>     ia[0]=(PetscInt)((k)*(my)*(mx)+(j)*(mx)+(i));
     
     This give the natural number of the location in ia[0]
>     AOPetscToApplication(ao,1,ia);

    So it makes no sense to call AOPetscToApplication() to map it to something else. It is already in the natural (i.e. application ordering)

>      w_localptr[k][j][i] = ia[0];
> PetscPrintf(PETSC_COMM_WORLD,"%d\n",ia[0]);
> }
> But this gives even lower number for the highest index.
> 
> Anyway my goal is to be able to determine the global natural index of the 
> grid within the for loops in the following way:
> for (k=zs; k<zs+zm; k++) {
>   for (j=ys; j<ys+ym; j++) {
>   for (i=xs; i<xs+xm; i++) {
> natural_global_coordinate(k',j',i')=f(k,j,i);
> if natural_global_coord[k'][j'][i'] > half of the grid along x {Do something}
> if natural_global_coord[k'][j'][i'] > half of the grid along y {Do something}

      i  > m/2  means means it is in the right half of the grid along x (where m is the number of grid points in the x direction).

      To determine these things you don't need to do anything about mapping between orderings.

      You are chasing yourself in circles to do something that is essentially trivial. With the loop structure you have above, the i,j,k ARE exactly the logical locations in the global X, Y, Z grid. It couldn't be simplier.
     
   Barry

> etc..
> }}} 
> Could you please suggest what would be the simplest way to achieve this. 
> Thanks in advance.
> 
> 
> 
> 
> 



More information about the petsc-users mailing list