<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 December 2016 at 16:49, Massoud Rezavand <span dir="ltr"><<a href="mailto:msdrezavand@gmail.com" target="_blank">msdrezavand@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Petsc team,<div><br></div><div>In order to create a parallel matrix and solve by KSP, is it possible to directly use MatSetValues() in runtime when each matrix entry is just created without MatMPIAIJSetPreallocation()?</div></div></blockquote><div><br></div><div>Yes, but performance will be terrible without specify any preallocation info.<br></div><div>See this note<br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html</a><br><br></div><div>For a code example of for how to do the assembly without preallocation (not recommended), you can refer to this (its the same pattern for MPIAIJ)<br><br><a href="http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex1.c.html">http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex1.c.html</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>I mean, when you only know the global size of Mat, and the number of nonzeros per row is not constant neither for all rows nor during time, is it possible to set the singular entries into Mat one by one after creating each one?</div></div></blockquote><div><br></div><div>Why don't you just destroy the matrix and create a new one every time the non-zero structure changes? <br>That's what I recommended last time.<br><br></div><div><br></div><div>Thanks,<br></div><div> Dave <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks</div><span class="gmail-HOEnZb"><font color="#888888"><div>Massoud</div><div><br></div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div></font></span></div>
</blockquote><br></div></div></div>