<div class="gmail_quote">On Sun, Jun 10, 2012 at 4:20 PM, Nakib Haider Protik <span dir="ltr"><<a href="mailto:nprot048@uottawa.ca" target="_blank">nprot048@uottawa.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":27x">Reason for two ksp objects:<br>
<br>
Multigrid and Domain Decomposition in PETSc<br>
Barry Smith<br>
PETSc Developer<br>
<br>
pg 28:<br>
<br>
//Use same pre and post smoother<br>
MGGetSmoother(pc,int level,KSP *ksp);<br>
<br>
<br>
//Use different pre and post smoother<br>
MGGetSmootherDown(pc,int level,KSP *dksp);<br>
MGGetSmootherUp(pc,int level,KSP *uksp);<br>
<br>
I was trying to use the second in my code.</div></blockquote><div><br></div><div>But you created two outer-level KSP objects, then leaked their memory when you overwrote their value when accessing the smoother on levels.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":27x"> I would be greatly helped if<br>
you could tell me where exactly my code goes wrong.<br></div></blockquote><div><br></div><div>The problem is that you are using the same local variable for every ksp arising in the code. When you get access to levels, you are overwriting the local variable. Since you did this so many times in various places where it was clearly not intended, I had assumed that you were not familiar with local variables in C. Everything that was incorrect with your code had to do with overwriting the local variable and later using it as though its original value was still intact. It would be better to explain what you are trying to achieve instead of posting code with nonsensical handling of local variables.</div>
<div><br></div><div>You should read through the code you posted and fix all these places (declare new variables of type KSP so you don't overwrite the outer ones). If you still have trouble, run in valgrind. It will tell you when you lose the reference to the outer objects.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":27x">
<br>
As for the "accidental" correctness of the 1d code, here's where I found<br>
the prototype:<br>
<br>
<a href="http://lists.mcs.anl.gov/pipermail/petsc-users/2011-May/008793.html" target="_blank">http://lists.mcs.anl.gov/pipermail/petsc-users/2011-May/008793.html</a><br>
<br>
If my question does not abide by the regulations of this mailing list, or<br>
if you are not obliged to answers questions of this kind, please let me<br>
know. I am not looking for free lessons on c, but thanks for the link.<br>
Despite the rude reply, thank you for taking the time.</div></blockquote></div><br>