[petsc-users] Difference between DMGetLocalVector and DMCreateLocalVector
Stefano Zampini
stefano.zampini at gmail.com
Thu Feb 22 03:24:25 CST 2024
I guess we are missing to clear the internal scratch vectors, matt can
confirm
Can you please add this call AFTER you set the local section to confirm?
call DMClearLocalVectors(dm_mesh, ierr);
Il giorno gio 22 feb 2024 alle ore 11:36 袁煕 <yuanxi at advancesoft.jp> ha
scritto:
> Hello, I found DMGetLocalVector and DMCreateLocalVector generate Vec of
> different size in my following codes ==================== call
> PetscSectionSetup(section,ierr) call
> DMSetLocalSection(dm_mesh,section,ierr) .. . . . . do somethingcall
> PetscSectionSetup(section,ierr)call
> ZjQcmQRYFpfptBannerStart
> This Message Is From an External Sender
> This message came from outside your organization.
>
> ZjQcmQRYFpfptBannerEnd
> Hello,
>
> I found DMGetLocalVector and DMCreateLocalVector generate Vec of
> different size in my following codes
>
> ====================
> call PetscSectionSetup(section,ierr)
> call DMSetLocalSection(dm_mesh,section,ierr)
> ......do something
>
> call PetscSectionSetup(section,ierr)
> call DMSetLocalSection(dm_mesh,section,ierr)
> ......
> call DMCreateLocalVector(dm_mesh,lvec,ierr);
> call DMGetLocalVector(dm_mesh,llvec,ierr);
> call VecGetSize(lvec,off,ierr)
> call VecGetSize(llvec,offl,ierr)
> call VecDestroy(lvec,ierr)
> call DMRestoreLocalVector(dm_mesh,llvec,ierr);
> ========================
> The pointer in the above program is that DMSetLocalSection is called two
> times. As the petsc manual indicates, "Any existing Section will be
> destroyed" after calling this function and To my understanding, a new
> section should be set. Therefore, The above program should obtain values
> of *off* and *offl *the same. However, I found that they are different,
> with *off *equal to the size defined by the new section and *offl* equal
> to the size defined by the first one.
>
> Any problem in above codes? And how can I obtain a Vector of the same size
> by DMGetLocalVector and DMCreateLocalVector?
>
> Much thanks for your help.
>
> X. Yuan, Ph.D. in Solid Mechanics
>
--
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240222/d517034e/attachment-0001.html>
More information about the petsc-users
mailing list