<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE link="#0563C1" vlink="#954F72" style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal>Hi everyone,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span lang=EN-US>I am having trouble with using SNES from petsc4py in PETSc 3.22. The problem is similar to <a href="https://gitlab.com/petsc/petsc/-/issues/1611">https://gitlab.com/petsc/petsc/-/issues/1611</a> 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<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>self.u.vector().vec().setArray(x)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>However, this now raises the error<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>[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)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I believe that this is a consequence of <a href="https://gitlab.com/petsc/petsc/-/merge_requests/7567#22c226fc29b6fc9dc5781b0aff4dcc70ac6c3489">https://gitlab.com/petsc/petsc/-/merge_requests/7567#22c226fc29b6fc9dc5781b0aff4dcc70ac6c3489</a>, 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<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>xx = x.getArray(readonly=True)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>as described in <a href="https://gitlab.com/petsc/petsc/-/issues/1611">https://gitlab.com/petsc/petsc/-/issues/1611</a> does not work either, as calling self.u.vector().vec().setArray(xx) then fails with the same error message.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Does anyone have an idea how to fix this? <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Thanks a lot in advance,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Sebastian<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>--<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Dr. Sebastian Blauth<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Fraunhofer-Institut für<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Techno- und Wirtschaftsmathematik ITWM<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Abteilung Transportvorgänge<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Fraunhofer-Platz 1, 67663 Kaiserslautern<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'>Telefon: +49 631 31600-4968<o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'><a href="mailto:sebastian.blauth@itwm.fraunhofer.de"><span style='color:blue'>sebastian.blauth@itwm.fraunhofer.de</span></a><o:p></o:p></span></p><p class=MsoNormal><span style='mso-ligatures:none;mso-fareast-language:DE'><a href="https://www.itwm.fraunhofer.de"><span style='color:blue'>https://www.itwm.fraunhofer.de</span></a><o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>