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

Matthew Knepley knepley at gmail.com
Fri Jul 17 07:41:24 CDT 2026


On Fri, Jul 17, 2026 at 8:37 AM Miguel Molinos <m.molinos at upm.es> wrote:

> 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?
>

Yes.


> 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"?
>

Ah, yes this is true. We had never used them in this way. A particle keeps
its "id" field throughout its life, so maybe it would make sense to have a
"local id" that changed after Migrate().

  Thanks,

     Matt


> 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
>
>
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!YxQf4rmDl7ZqlCOcNJWUdFvIgkmlPa2cBjnracjF0EyZ3gULeyJkmkdeGSBsEKyIXR8yutAE60oiApARp7cI$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!YxQf4rmDl7ZqlCOcNJWUdFvIgkmlPa2cBjnracjF0EyZ3gULeyJkmkdeGSBsEKyIXR8yutAE60oiArE4RsRw$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260717/e796edca/attachment.html>


More information about the petsc-users mailing list