Hi everyone,
I am having trouble with using SNES from petsc4py in PETSc 3.22. The problem is similar to https://gitlab.com/petsc/petsc/-/issues/1611 and related to the readonly access of “x”. Particularly, in my application, based on FEniCS, I want to solve a nonlinear PDE. Therefore, in my callbacks, I want to set the vector of DoFs of my FEniCS function to “x” with a line like
self.u.vector().vec().setArray(x)
However, this now raises the error
[0] Vector 'Vec_0x84000003_0' (argument #1) was locked for read-only access in unknown_function() at unknown file:0 (line numbers only accurate to function begin)
I believe that this is a consequence of https://gitlab.com/petsc/petsc/-/merge_requests/7567#22c226fc29b6fc9dc5781b0aff4dcc70ac6c3489, but I did not find any information on how to remove the lock from the vector or how I can set use “x” to update the vector of my function. Using
xx = x.getArray(readonly=True)
as described in https://gitlab.com/petsc/petsc/-/issues/1611 does not work either, as calling self.u.vector().vec().setArray(xx) then fails with the same error message.
Does anyone have an idea how to fix this?
Thanks a lot in advance,
Sebastian
--
Dr. Sebastian Blauth
Fraunhofer-Institut für
Techno- und Wirtschaftsmathematik ITWM
Abteilung Transportvorgänge
Fraunhofer-Platz 1, 67663 Kaiserslautern
Telefon: +49 631 31600-4968
sebastian.blauth@itwm.fraunhofer.de
https://www.itwm.fraunhofer.de