[petsc-users] `VecCreateGhostWithArray` ownership layout vs application indices after migrate

Miguel Molinos m.molinos at upm.es
Fri Jul 17 07:32:57 CDT 2026


Dear all,

I am using "VecCreateGhostWithArray" to wrap particle fields (positions, densities, etc.) stored in a “DMSwarm" structure. On each rank the local array is packed as [owned particles | ghost particles].

My understanding from the implementation in pbvec.c is:

1. “PetscSplitOwnership" + "VecSetSizes(n, N)" assigns each rank a contiguous ownership range [rstart, rstart+n).
2. Local owned entry "I" therefore corresponds to global index "rstart + I".
3. The ghosts[] array in “ VecCreateGhostWithArray" must contain those PETSc global vector indices, because “VecGhostUpdate" scatters from the global vector into the local ghost padding.

Is that correct?

If so, after rebalancing particles with “DMSwarmMigrate", the application “AO" numbering attached to each particle is no longer the same as the contiguous ownership of a newly created ghosted Vec. In that case, should one always renumber the owned particle ids to "rstart + I" (and let ghosts inherit those ids) before calling “VecCreateGhostWithArray"?

Thanks,  
Miguel

Miguel Molinos

Escuela de Ingenieros de Caminos, Canales y Puertos
Dep. Mecánica Medios Continuos y Teoría de Estructuras

Prof. Aranguren, 3 - Ciudad Universitaria.
Planta 9. 28040, Madrid



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260717/139ba9ab/attachment.html>


More information about the petsc-users mailing list