see this example: https://github.com/JesseLu/petsc4py-tutorial/blob/master/mat_serial.py
You need to add the assembly calls On Mon, Oct 18, 2021 at 10:06 AM Guangpu Zhu <[email protected]> wrote: > Dear Sir/Madam, > > My name is Guangpu Zhu, I met a problem when I tested the matrix > operation in petsc4py. 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 > > > > --- > Guangpu Zhu > > Research Associate, Department of Mechanical Engineering > > National University of Singapore > > Personal E-mail: [email protected] > > Phone: (+65) 87581879 >
