[petsc-dev] xlocal = da.getLocalVec() .. da.restoreLocalVec(xlocal) skip the restore

Matthew Knepley knepley at gmail.com
Wed Feb 1 19:07:57 CST 2023

On Wed, Feb 1, 2023 at 6:33 PM Barry Smith <bsmith at petsc.dev> wrote:

>   Would it be possible to rig the xlocal obtained from
> self.da.getLocalVec()  to automatically trigger the da.restoreLocalVec()
> when the xlocal goes out of scope so that the user does not need to
> explicitly make the call. If so, how should I go about implementing it?

This would work in C++ where the object has a defined lifetime, but Python
is garbage collected. The way it does this
pattern is using the "with" statement.


>   Barry
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://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20230201/fef6fa26/attachment.html>

More information about the petsc-dev mailing list