<div dir="ltr">see this example: <a href="https://github.com/JesseLu/petsc4py-tutorial/blob/master/mat_serial.py">https://github.com/JesseLu/petsc4py-tutorial/blob/master/mat_serial.py</a><div><br></div><div>You need to add the assembly calls</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 18, 2021 at 10:06 AM Guangpu Zhu <<a href="mailto:zhugp01@nus.edu.sg">zhugp01@nus.edu.sg</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Cambria,Georgia,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="margin:0px;font-size:12pt;color:black;background-color:rgb(255,255,255)">Dear Sir/Madam,</span></div>
<div style="font-family:Cambria,Georgia,serif;font-size:12pt;color:rgb(0,0,0)">
<div style="margin:0px;font-size:12pt;color:black;background-color:rgb(255,255,255)">
<br>
</div>
<span style="margin:0px;font-size:12pt;color:black;background-color:rgb(255,255,255)">         My name is Guangpu Zhu, I met a problem when I tested the matrix operation in petsc4py.  <span style="margin:0px">As the following code shows, I first set all elements
 of the matrix to 2.0. Then, I try to set the diagonal elements of the matrix to 1.0.  However, I surprisingly found that the diagonal elements are still 2.0.  This question has confused me for a few days, so I am writing to you for help or suggestions. Attached
 is the test code I used. I would greatly appreciate it if you can kindly reply to me. Thank you in ad</span></span><br>
</div>
<div style="font-family:Cambria,Georgia,serif;font-size:12pt;color:rgb(0,0,0)">
<span style="margin:0px;font-size:12pt;color:black;background-color:rgb(255,255,255)"><span style="margin:0px"><br>
</span></span></div>
<div style="font-family:Cambria,Georgia,serif;font-size:12pt;color:rgb(0,0,0)">
<img style="max-width: 100%;" size="18308" src="cid:17c93ce0c8ecb971f161"><br>
</div>
<div>
<div style="font-family:Cambria,Georgia,serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-8445151776567957885Signature">
<div>
<div></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
---</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:Cambria,Georgia,serif">Guangpu Zhu</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:Cambria,Georgia,serif">Research Associate,  Department of Mechanical Engineering</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="color:rgb(0,0,0);font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="color:rgb(0,0,0);font-family:Cambria,Georgia,serif;font-size:12pt">National University of Singapore</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:Cambria,Georgia,serif">Personal E-mail: <a href="mailto:zhugpupc@gmail.com" target="_blank">zhugpupc@gmail.com</a></span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:Cambria,Georgia,serif"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-size:12pt;font-family:Cambria,Georgia,serif">Phone: (+65) 87581879</span></div>
</div>
</div>
</div>
</div>

</blockquote></div>