[petsc-users] How to create a mapping of global to local indices?

Mark Adams mfadams at lbl.gov
Wed Jul 3 08:54:49 CDT 2019


PETSc matrices and vectors are created with a local size n or global size N
and PETSC_DECIDE instead of n. The global PETSc indices are ordered from 0
to n_0 - 1 where n_0 is the number of equations on process 0. This
numbering continues for all processes.

You can use:

PetscErrorCode <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode>
MatGetOwnershipRange
<https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetOwnershipRange.html#MatGetOwnershipRange>(Mat
<https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html#Mat>
mat,PetscInt <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInt.html#PetscInt>
*m,PetscInt <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInt.html#PetscInt>
*n)

To see what your local global indices are (rows m to n-1 are on this
process and so its the local indices are 0 to (n-m-1)).

Mark


On Wed, Jul 3, 2019 at 9:11 AM Dongyu Liu - CITG via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi,
>
>
> I am running a FEM program using PETSc. In the beginning,  the mesh is
> partitioned in gmsh, and we read the partitioned mesh using our own reader.
>
>
> Now my question is: How can I get a global to local indices mapping? and
> do I need to renumber the indices after I read the partitioned mesh?
>
>
> From my understanding, the rows handled by each processor should be
> consecutive, but the indices of nodes which I directly read from a gmsh
> file are not. Is this an issue?
>
>
> Best,
>
>
> Dongyu
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190703/35493316/attachment.html>


More information about the petsc-users mailing list