<div dir="ltr">Maybe I should create a separate question for this but I did some testing and now I'm a bit confused on how PETSc handles preallocated space which is not assigned a value. I created a test case where I allocated a certain amount of space for a matrix. I then only assigned a value to the (0,0) entry and assembled the matrix. When I look at the MatInfo it says that there were 0 unneeded entries. Furthermore, when I use MatView, I see that there are 0 values in the matrix so there actually were values which were put there. <div><br></div><div>I have a guess at what's happening and if I'm correct then it would solve my original problem but I would like to confirm here. I am using the MatPreallocator class along with the MatPreallocatorPreallocate() routine to allocate space for the matrix. My guess is that this routine automatically assigns a value of zero to the entries which I specified in the preallocator. So if I had done the original MatXXXAIJSetPreallocation() routines which just allocate a certain number of non-zeros to the rows, then I would have to explicitly assign them zero values or else I would lose unassigned space in the assembly routines. Since the MatPreallocator specifies exactly which entries will be non-zero, PETSc also actually assigns a zero value under the hood so that I don't have to explicitly assign values myself. Is this correct?</div><div><br></div><div>Sorry for the convoluted question. I hope it's clear. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 12, 2022 at 11:54 AM Samuel Estes <<a href="mailto:samuelestes91@gmail.com">samuelestes91@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have a problem where I want to allocate some nonzero structure to a sparse matrix which will be used repeatedly to solve some equations. The assembly routines will compress out allocated space which has not been assigned a value so I know that I need to assign zero values to any unused entries in order to keep that space. Will MatZeroEntries do this? If not, I could always just loop over and explicitly assign zero values but MatZeroEntries would be more convenient. Thanks!</div></div>
</blockquote></div>