[petsc-users] `VecCreateGhostWithArray` ownership layout vs application indices after migrate
Miguel Molinos
m.molinos at upm.es
Fri Jul 17 07:47:52 CDT 2026
Thank you Matt, your answer helps a lot!
Miguel
> On 17 Jul 2026, at 14:41, Matthew Knepley <knepley at gmail.com> wrote:
>
> On Fri, Jul 17, 2026 at 8:37 AM Miguel Molinos <m.molinos at upm.es <mailto: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!aCColzrodwSPfu9V220li2ogOrsBlxqgZ8d9rrioRvzYWkDvea9H_NP3jOGs_Hf8V8c12bV6LjeQGZmAIZsqFdie$ <https://urldefense.com/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!D9dNQwwGXtA!TQyfZBM_3vA0PVKt2YVzQKSJ1aOYktyIPAnGFKRrPrvPuYJWkzdY3meEL8rcIX4oSP3yECm5TLAKzo4$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20260717/033f2dcc/attachment-0001.html>
More information about the petsc-users
mailing list