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'm concerned with PETSc, running on a single processor, I'm using the command line argument "-info" 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 "global" 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'm having twice more nonzero elements (I tested against a tiny simulation on a single processor). It seems that on the output I'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 "unneeded" field has some value and another that this field is zero. Then I decided to discard the information where the field "unneeded" 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 "0 unneeded" and (2) if there is a more elegant way to measure this.<br><br>That's all! <br>Best regards,<br>Bernardo M. R.<br>