<div dir="ltr">Hi Guys,<div><br></div><div>I'm now confronting a problem.</div><div><br></div><div>I'm using PETSC to construct a SPARSE Matrix. And I'm sure that the matrix has been allocated correctly using  <b>MatMPIAIJSetPreallocation </b>with the upper limit of the size.</div><div><b><br></b></div><div>The code works well when I just solve the system once.</div><div><br></div><div>However, after the system been solved. And I want to use the original non-zero structure, but change the elements inside the matrix. The petsc will show the error message as:</div><div><br></div><div><div>[14]PETSC ERROR: Argument out of range</div><div>[14]PETSC ERROR: New nonzero at (58,56) caused a malloc</div><div>Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check</div></div><div><br></div><div>My current the solution is destroy the system and reallocate with the same size. But I believe there should be more efficient way, i.e. just use the original structure.</div><div><br></div><div>I would like search for help to confirm that whether PETSC will compress/delete the zero entries during the MatAssemblyBegin/MatAssemblyEnd/KSPSolve, or other possible places.</div><div><br></div><div>And how to avoid deleting zero elements during the process?</div><div><br></div><div>Thanks very much.</div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback","Noto Color Emoji";font-weight:normal;font-size:14px;line-height:19px;white-space:pre"><div><br></div></div></div><div><br></div><div><br></div><div><b><br></b></div><div><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-size:14px;line-height:21px;font-family:宋体"><span style="font-size:10.5pt">Qicang SHEN</span><br></div><div style="font-size:14px;line-height:21px;font-family:宋体">PhD Candidate</div><div style="font-size:14px;line-height:21px;font-family:宋体"><div>Nuclear Engineering and Radiological Sciences, University of Michigan, Ann Arbor</div></div><div style="font-size:14px;line-height:21px;font-family:宋体"><span style="font-size:10.5pt">Email: q</span><span style="font-size:10.5pt"><a href="mailto:icangsh@umich.edu" target="_blank">icangsh@umich.edu</a></span></div></div></div></div></div></div></div></div></div></div></div></div>