You are right. I was not clearing the caches when the section was reset. Stefano ahs fixed this now:
https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/7314__;!!G_uCfscf7eWS!ZPkq_k9vdzTZxeW53aWVTIcDgeGnywSm0tGKDJkJqdwgTomfYjw1lsTMyRtAjtruSslcgLIoKGg7IILlBxbJ$ Thanks, Matt On Thu, Feb 22, 2024 at 4:24 AM Stefano Zampini <[email protected]> wrote: > 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 袁煕 <[email protected]> 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 > -- 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!ZPkq_k9vdzTZxeW53aWVTIcDgeGnywSm0tGKDJkJqdwgTomfYjw1lsTMyRtAjtruSslcgLIoKGg7IIE6dMV7$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZPkq_k9vdzTZxeW53aWVTIcDgeGnywSm0tGKDJkJqdwgTomfYjw1lsTMyRtAjtruSslcgLIoKGg7IH_eS1w6$ >
