<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 22, 2016 at 11:54 AM, ehsan sadrfaridpour <span dir="ltr"><<a href="mailto:it.sadr@gmail.com" target="_blank">it.sadr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Thanks a lot for your prompt reply and useful advice. <br></div><br>I have another question. In my current case, I don't change any value in the sub-vector and in another words I used it as read-only.<br></div>What should I do after I don't need it anymore?<br>Should I call VecRestoreSubVector method or it is faster if I call the Destroy method on the sub-vector ?<br></div></div></div></div></div></blockquote><div><br></div><div>Restore not Destroy for subvec.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div></div>If I understand you correctly, the subvector doesn't have any space for itself, in that case Destroy method does not release the memory.<br><br></div>And finally, I destroy the original vector after I call either Restore or Destroy on the sub-vector.<br></div></div></div></blockquote><div><br></div><div>Yes, after Restore.</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"><div dir="ltr"><div><div></div>Best,<br></div>Ehsan<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 22, 2016 at 12:44 PM, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Wed, Jun 22, 2016 at 9:21 AM, ehsan sadrfaridpour <span dir="ltr"><<a href="mailto:it.sadr@gmail.com" target="_blank">it.sadr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br></div><br>If I use VecGetSubVector to get a subvector it works fine as far as I don't destroy the original vector.<br></div>But, if I destroy the original vector, I get NaN values. So, it is my misunderstanding of what the function suppose to do, or is it a problem?<br></div></div></div></div></blockquote><div><br></div></span><div>You cannot destroy the original vector since you still need to call</div><div><br></div><div> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecRestoreSubVector.html#VecRestoreSubVector" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecRestoreSubVector.html#VecRestoreSubVector</a></div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div></div>I do the same thing with <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSubMatrix.html#MatGetSubMatrix" style="font-family:"Times New Roman";font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)" target="_blank">MatGetSubMatrix</a> and I haven't had any problem with it.<br></div></div></div></blockquote><div><br></div></span><div>MatGetSubMatrix() is a hybrid since for INITIAL_MATRIX it creates a new matrix, whereas for REUSE_MATRIX it refills and existing</div><div>one. However there is not Restore().</div><div><br></div><div><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSubMatrix.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSubMatrix.html</a><br></div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div></div>Best,<br></div>Ehsan<span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br><br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div data-smartmail="gmail_signature">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>
</font></span></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">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></div>