[petsc-users] DM Vector get vs. create

Barry Smith bsmith at mcs.anl.gov
Wed May 6 17:32:09 CDT 2015


> On May 6, 2015, at 5:24 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
> 
> What are the relative merits of DMGetGlobalVector and DMCreateGlobalVector, and the analogous question for the Local Vectors?  Are there scenarios where one should be used over the other?

   Get are intended for obtaining work vectors that one intends to restore soon, likely in the same function that did the get. Create is for long living vectors that you are likely passing around to solvers, subroutines etc.

    Explanation: sometimes a subroutine needs some work vectors. For example often a PETSc SNESFormFunction will do a DMGlobalToLocalBegin/End() at the beginning to allow access of ghost values. That local vector is only needed in that subroutine so one should use the get.


> 
> -gideon
> 



More information about the petsc-users mailing list