<div dir="ltr"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 21, 2013 at 11:50 PM, iwaddington . <span dir="ltr"><<a href="mailto:iwaddington@gmail.com" target="_blank">iwaddington@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">But still regarding the issue of setting the matrix that will be used to build the preconditioner, what would be the way to do it in the function that I described you before , without the use of matcopy to make it equal to the system matrix set with MatSetValuesStencil? My idea is to use the conjugate gradient method. Sorry to bother so much, but I am learning petsc all by myself.<div>
<div class="h5"><br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 21, 2013 at 11:27 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"><div>On Thu, Nov 21, 2013 at 7:24 PM, iwaddington . <span dir="ltr"><<a href="mailto:iwaddington@gmail.com" target="_blank">iwaddington@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">My idea is to use MatSetValuesStencil to set the system matrix, because I am dealing with a dmda, and regarding the prototype, I know that what is written in the web page is different, but when you look further in the <a href="http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/interface/itfunc.c.html#KSPSetComputeOperators" target="_blank">src/ksp/ksp/interface/itfunc.c</a> and also the example files you see that my prototype is in fact the right one.</div>
</blockquote><div><br></div></div><div>I will fix the docs. Yes, just call MatSetValuesStencil.</div><div><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 class="gmail_extra"><div class="gmail_quote">On Thu, Nov 21, 2013 at 11:15 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"><div>On Thu, Nov 21, 2013 at 7:08 PM, iwaddington . <span dir="ltr"><<a href="mailto:iwaddington@gmail.com" target="_blank">iwaddington@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div>Thanks Matthew, but how exactly do I do that in a user defined function of the form used by <span>KSPSetComputeOperators</span>:<br>
</div></div></div></blockquote><div><br></div></div><div>There are a few problems here:</div><div><br></div><div>1) Your prototype is wrong:</div><div><br></div><div> <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetComputeOperators.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetComputeOperators.html</a></div>
<div><br></div><div>2) Regardless, people generally use the matrix that is passed in. Thus you call</div><div><br></div><div> MatSetValues(*J, ...)</div><div><br></div><div> Why are you not doing this?</div><div><br>
</div>
<div>3) It is customary if you have the same system and preconditioner matrix to assemble into the preconditioner</div><div><br></div><div> Matt</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div><div>#undef __FUNCT__<br>#define __FUNCT__ "ComputeMatrix"<br>
PetscErrorCode ComputeMatrix(KSP ksp, Mat J,Mat jac,MatStructure *str, void *ctx)<br>{<br><br></div><div>/* variables */<br></div><div><br> PetscFunctionBeginUser;<br><br></div>/* Setting the system linear matrix J*/<br>
<br></div>/* Now I want to set jac=J which is the preconditioning matrix in this part , my first idea was to use matcopy, but I would like something more efficient */<br><br> PetscFunctionReturn(0);<br> <br>}<br><div><br>
<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 21, 2013 at 10:26 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>On Thu, Nov 21, 2013 at 6:21 PM, iwaddington . <span dir="ltr"><<a href="mailto:iwaddington@gmail.com" target="_blank">iwaddington@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Sorry Matthew, but I didn't understand what you said, because it is not the case of passing arguments to a function, I have to write the function which I will later pass to <span>KSPSetComputeOperators</span>, and in the function I have to set the system linear matrix and preconditioning matrix.</div>
</blockquote><div><br></div></div><div>You can return the same matrix for the system and preconditioner.</div><div><br></div><div> Matt</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 21, 2013 at 10:00 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>On Thu, Nov 21, 2013 at 5:44 PM, iwaddington . <span dir="ltr"><<a href="mailto:iwaddington@gmail.com" target="_blank">iwaddington@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>HI everybody, I have a doubt concerning how the function KSPSetComputeRHS works, because according to its prototype one of its arguments is a pointer to a function that takes a vector object as argument, not a pointer towards a vector object, so how is it able to set the rhs if the passage of the vector is done by value and not by reference ?<br>
</div></div></blockquote><div><br></div></div><div>The values of the Vec can be set, rather than changing the object pointer itself.</div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div></div>Another thing is the functioning of KSPSetComputeOperators. I want to set the linear system matrix and I want the preconditioning matrix to be equal, so can I just set the linar system matrix in the function that is argument of KSPSetComputeOperators, or do I need to make a matcopy in it ?<br>
</div>
</blockquote></div></div><br>No, just give the same argument twice.</div><div class="gmail_extra"><br></div><div class="gmail_extra"> Matt<span><font color="#888888"><span><font color="#888888"><span><font color="#888888"><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
</font></span></font></span></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></div></div><span><font color="#888888"><div><br><br clear="all"><span><font color="#888888"><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
</font></span></div></font></span></div></div><span><font color="#888888">
</font></span></blockquote></div><span><font color="#888888"><br></font></span></div><span><font color="#888888">
</font></span></blockquote></div></div></div><span><font color="#888888"><div><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></font></span></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div><div><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></div></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>