[petsc-users] Difference between DMGetLocalVector and DMCreateLocalVector

袁煕 yuanxi at advancesoft.jp
Thu Feb 22 02:36:03 CST 2024


 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240222/a0e9d49e/attachment.html>


More information about the petsc-users mailing list