Thanks a lot! =)<br><br><div class="gmail_quote">2009/9/15 Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
You can use the output of -ksp_view, which gives the matrix information.<br><br> Matt<div><div></div><div class="h5"><br><br><div class="gmail_quote">On Tue, Sep 15, 2009 at 2:01 PM, Bernardo Rocha <span dir="ltr"><<a href="mailto:bernardosk@gmail.com" target="_blank">bernardosk@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">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>
</blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>
</font></blockquote></div><br>