"Smith, Barry F. via petsc-users" <petsc-users@mcs.anl.gov> writes:
>> On Jan 8, 2019, at 4:11 PM, Fande Kong via petsc-users >> <petsc-users@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() If the value may be in your ghosted/halo region, you can use VecGetLocalToGlobalMapping(vec, ltog); ISLocalToGlobalMappingApply(ltog, 1, &local, &global);