[petsc-users] Fwd: what is the equivalent DMDAVecRestoreArray() function in petsc4py?

Jed Brown jed at jedbrown.org
Thu Feb 15 15:33:27 CST 2018


HeeHo Park <heeho.park at gmail.com> writes:

> Yes, this works.
>
> u = da.getVecArray(U)
> for i in range(mstart, mend):
>         u[i] = np.sin(np.pi*i*6.*h) + 3.*np.sin(np.pi*i*2.*h)
>
> The code above also worked without restoreVecArray. I guess the u just
> points at the array U.

It won't be restored until u goes out of scope, and even that would
depend on the Python implementation.  Use the "with" context manager.


More information about the petsc-users mailing list