Hi everyone,<br><br>I need to know the number of nonzero element of the matrix in an application using PETSc. How can I do it? What is the best way to do it?<br><br>As far as I&#39;m concerned with PETSc, running on a single processor, I&#39;m using the command line argument &quot;-info&quot; and then I get this information in some line of the output that looks like this<br>
<br>[0] MatAssemblyEnd_SeqAIJ(): Matrix size: 5100 X 5100; storage space: 92706 unneeded,44994 used<br><br>then I simply get the number of used entries. <br><br>But when I have a large simulation, where the matrix does not fit into the memory of one processor, I must use several processors. My question is how to get the number of nonzero entries of the &quot;global&quot; matrix? I wrote a simple python script to parse the output and sum the number of entries used on each processor, but I found out that my calculations are wrong, I&#39;m having twice more nonzero elements (I tested against a tiny simulation on a single processor). It seems that on the output I&#39;m parsing I have two kinds of informations about the entries used:<br>
<br>[0] MatAssemblyEnd_SeqAIJ(): Matrix size: 5100 X 5100; storage space: 92706 unneeded,44994 used<br><br>[0] MatAssemblyEnd_SeqAIJ(): Matrix size: 5100 X 5100; storage space: 0 unneeded,44994 used<br><br>That is, one that the &quot;unneeded&quot; field has some value and another that this field is zero. Then I decided to discard the information where the field &quot;unneeded&quot; is zero and finally the results matched perfectly with a single processor case.<br>
<br>So, i would like to know (1) why do I have these lines with &quot;0 unneeded&quot; and (2) if there is a more elegant way to measure this.<br><br>That&#39;s all! <br>Best regards,<br>Bernardo M. R.<br>