<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 16, 2014 at 9:00 AM, Eric Chamberland <span dir="ltr"><<a href="mailto:Eric.Chamberland@giref.ulaval.ca" target="_blank">Eric.Chamberland@giref.ulaval.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 04/16/2014 09:44 AM, Jed Brown wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Eric Chamberland <<a href="mailto:Eric.Chamberland@giref.ulaval.ca" target="_blank">Eric.Chamberland@giref.<u></u>ulaval.ca</a>> writes:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I was writing (new) code which do the firsts MatSetValues after the<br>
MatXAIJSetPreallocation.  We have to do this because the "real"<br>
non-zeros will be added later by a mix of ADD_VALUES and<br>
INSERT_VALUES... which would prevent us to "lock" the matrix<br>
(MatSetOption(aMatricePETSc, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE)<br>
because this option must be passed after the first MatAssemblyEnd()...<br>
but all the non-zeros are "triggered" only after this "mixed" assembly...<br>
<br>
In other words, we have to do a "fake" assembly with all "0" to cover<br>
all non-zeros that will be in fact added later... So we have to create<br>
many "fake" elementary matrices to pass for assembly... that is why<br>
Patrick was asking if the feature was supported... It would save us from<br>
creating the fake matrices...  Or maybe there is a better solution?...<br>
</blockquote>
Just create one large-enough buffer containing all zeros.  For example,<br>
<br>
   PetscScalar *values;<br>
   PetscCalloc1(1000,&values);<br>
<br>
   for (...) {<br>
     MatSetValues(...,values,<u></u>INSERT_VALUES);<br>
   }<br>
   PetscFree(values);<br>
<br>
Is this okay?<br>
</blockquote>
Yes this can be ok.<br>
<br>
I have a new question now : what would be the fastest way to do the first assembly: with INSERT_VALUES or ADD_VALUES?  Right now we are doing ADD_VALUES but I imagine it have to hold all the "0" which will be "added" later... maybe "INSERT_VALUES" will forget about overlapping values??...  Anyway, the code I am rewriting now will hold all the non-zeros for each "block" of similar lines... so I don't have overlapping values... in sequential... but in parallel I think I will have some... Anyway, any pros/cons between INSERT_VALUES or ADD_VALUES for this first assembly?<br>
</blockquote><div><br></div><div>There should not be any significant difference. I would use INSERT.</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>
<br>
Eric<br>
<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <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
</div></div>