[petsc-users] accessing DMDA Vec ghost values
Sean Dettrick
sdettrick at trialphaenergy.com
Thu May 12 11:05:40 CDT 2016
Thanks Matt and Dave for the explanation, that is very helpful.
Best
Sean
On Thu, May 12, 2016 at 8:58 AM -0700, "Dave May" <dave.mayhem23 at gmail.com<mailto:dave.mayhem23 at gmail.com>> wrote:
Matt beat me to the punch... :D
Anyway, here is my more detailed answer.
Thanks! Somehow I missed DM{Get,Create}LocalVector(). BTW what is the difference between the Get and Create versions? It is not obvious from the documentation.
The DMDA contains a pool of vectors (both local and global) which can be re-used by the user. This avoids the need to continually allocate and deallocate memory. Thus, the Get methods are simply an optimization.
The Get methods retrieve from the pool, a vector which isn't currently in use. In this case, You can think of Restore as returning the vector back to the pool to be used somewhere else.
If all vectors in the pool are in use, a new one will be allocated for you. In this case, Restore will actually deallocate memory.
Since Get methods may return vectors which have been used else where in the code, you should always call VecZeroEntries() on them.
The Create methods ALWAYS allocate new memory and thus you ALWAYS need to call Destroy on them. Vectors obtained via VecCreate() will always be initialized with 0's.
Thanks,
Dave
Also, can you explain the difference between DMDAVecGetArrayDOF and DMDAVecGetArrayDOFRead?
Thanks again,
Sean
Thanks,
Dave
Thanks very much!
Sean Dettrick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160512/12cbe0ff/attachment.html>
More information about the petsc-users
mailing list