<div class="gmail_quote">On Sun, Jun 10, 2012 at 3:49 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=":tf">Thank you very much for the reply. Here's a change that works for the 2D<br>
case:<br>
<br>
////////////////////MG Solver Stuff////////////////////<br>
    KSPCreate(PETSC_COMM_WORLD, &ksp);<br>
    KSPSetType(ksp, KSPGMRES);<br>
<br>
    KSPCreate(PETSC_COMM_WORLD, &kspu);<br>
    KSPSetType(kspu, KSPGMRES);<br></div></blockquote><div><br></div><div>Why do you have two KSPs here?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":tf">
<br>
    KSPGetPC(ksp, &pc);<br>
    KSPGetPC(kspu, &pc);<br></div></blockquote><div><br></div><div>Why?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":tf">
<div class="im"><br>
    PCSetType(pc, PCMG);<br>
    PCMGSetLevels(pc, 2, PETSC_NULL);<br>
    PCMGSetType(pc, PC_MG_MULTIPLICATIVE);<br>
    PCMGSetCycleType(pc, PC_MG_CYCLE_V);<br>
    MatDuplicate(A, MAT_COPY_VALUES, &P);<br>
    PCMGSetCyclesOnLevel(pc, 0, 1);<br>
    PCMGSetCyclesOnLevel(pc, 1, 1);<br>
    PCMGGetCoarseSolve(pc, &ksp);<br>
</div>    PCMGGetSmootherDown(pc, 0, &ksp);<br>
    PCMGGetSmootherUp(pc, 1, &kspu);//(*)//<br></div></blockquote><div><br></div><div>Okay, clearly you need to learn how variables work in C. Here is a free resource.</div><div><br></div><div><a href="http://c.learncodethehardway.org/book/">http://c.learncodethehardway.org/book/</a></div>
<div><br></div><div>(Any other resource will also do.) When you are comfortable with the language, we can revisit your code.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":tf">
<div class="im">    PCMGSetInterpolation(pc, 1, P);<br>
    PCMGSetRestriction(pc, 1, P);<br>
</div>    PCMGSetResidual(pc, 0, PCMGDefaultResidual, P);<br>
    PCMGSetResidual(pc, 1, PCMGDefaultResidual, P);<br>
    KSPSetOperators(ksp, A, P, SAME_NONZERO_PATTERN);<br>
<div class="im">    KSPSetFromOptions(ksp);<br>
    KSPSolve(ksp, breal, xreal_harm);<br>
    KSPSolve(ksp, bimag, ximag_harm);<br>
</div>    //////////////////////////////////////////////////////////<br>
<br>
Do you think this is working again because of some accident? Without the<br>
step marked with a //(*)//, the code works too.</div></blockquote></div><br>