On Mon, May 3, 2010 at 8:15 AM, Sander Land <span dir="ltr">&lt;<a href="mailto:sander.land@comlab.ox.ac.uk">sander.land@comlab.ox.ac.uk</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I am preallocating a matrix using<br>
  MatMPIAIJSetPreallocation(HalfM,27,PETSC_NULL,26,PETSC_NULL);<br>
Since I have no easy way to know whether the entries will end up in<br>
petsc&#39;s &#39;diagonal&#39; or &#39;nondiagonal&#39;. After assembling the matrix this<br>
results in:<br>
<br>
Matrix Object:<br>
 type=mpiaij, rows=9801, cols=9801<br>
 total: nonzeros=231601, allocated nonzeros=519453<br>
   [0] Local rows 9801 nz 231601 nz alloced 519453 mem 6551364, not<br>
using I-node routines<br>
   [0] on-diagonal part: nz 231601<br>
   [0] off-diagonal part: nz 0<br>
<br>
On 1 processor, and some numbers split between on/off on more, as<br>
expected. So far no problem since I can temporarily spare the memory<br>
for 1 such matrix.<br>
Next, I would like to compress the storage somehow, to free the memory<br>
not used, since I know this nonzero pattern will not change, but I<br>
can&#39;t find a way to do this in petsc.<br>
Worse, when I use MatConvert/MatDuplicate to initialize my other<br>
matrices, they all seem to inherit this property of using about twice<br>
as much memory as needed. This is a problem when taking the number of<br>
rows to 1 million +.<br>
<br>
What is the easiest way to free the unused memory?<br></blockquote><div><br></div><div>MatAssemblyBegin/End() frees the unused memory, so you must be calculating the</div><div>amount of memory needed incorrectly. Remember that memory is necessary not only</div>
<div>for the values, but the indexing structures.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks,<br>
<font color="#888888">Sander Land<br>
</font></blockquote></div><br><br clear="all"><br>-- <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>