[petsc-users] In a 2D DMDA object, how to convert (i, j) to a global index?

Smith, Barry F. bsmith at mcs.anl.gov
Tue Jan 8 16:29:34 CST 2019



> On Jan 8, 2019, at 4:11 PM, Fande Kong via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hi All,
> 
> I was wondering how to convert a regular (2D DMDA) grid coordinate (i,j) to a global index that is used for global matrices and vectors. Do we have any API on this? 

    You can convert the global i,j to a local I,J by subtracting off the xs, ys, then convert to the local vector numbering with something like I+J*xm then add that value to the rstart returned from VecGetOwnershipRange() 

   Barry

> 
> Thanks,
> 
> Fande Kong,



More information about the petsc-users mailing list