<br><br><div class="gmail_quote">On Tue, Feb 26, 2013 at 8:59 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On Feb 26, 2013, at 9:54 PM, Dmitry Karpeev <<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>> wrote:<br>
<br>
> Here's what I get with this simple example (source and makefile also attached):<br>
><br>
><br>
> #include <petscksp.h><br>
><br>
> #undef __FUNCT__<br>
> #define __FUNCT__ "main"<br>
> int main(int argc,char **args)<br>
> {<br>
> KSP ksp;<br>
> PetscErrorCode ierr;<br>
> PetscInitialize(&argc,&args,(char*)0,(char*)0);<br>
> ierr = KSPCreate(PETSC_COMM_WORLD, &ksp);CHKERRQ(ierr);<br>
> ierr = KSPSetPCSide(ksp, PC_RIGHT);CHKERRQ(ierr);<br>
> ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);<br>
> ierr = KSPDestroy(&ksp);CHKERRQ(ierr);<br>
> PetscFinalize();<br>
> }<br>
><br>
><br>
> Then<br>
><br>
> [hal3 Tue Feb 26 09:34 PM] ~/petsc/dev/c/src/ksp/ksp/examples/tutorials/tmp >./ex -ksp_type preonly -ksp_pc_side left<br>
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>
> [0]PETSC ERROR: No support for this operation for this object type!<br>
> [0]PETSC ERROR: KSP preonly does not support RIGHT!<br>
> [0]PETSC ERROR: ------------------------------------------------------------------------<br>
> [0]PETSC ERROR: Petsc Development HG revision: 55699a42ce9360fb4641931ab7ec242cba302c58 HG Date: Mon Feb 25 22:15:44 2013 -0500<br>
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>
> [0]PETSC ERROR: See docs/index.html for manual pages.<br>
> [0]PETSC ERROR: ------------------------------------------------------------------------<br>
> [0]PETSC ERROR: ./ex on a arch-gxx-real named hal3 by karpeev Tue Feb 26 21:37:13 2013<br>
> [0]PETSC ERROR: Libraries linked from /home/karpeev/petsc/dev/c/arch-gxx-real/lib<br>
> [0]PETSC ERROR: Configure run at Tue Feb 26 17:50:35 2013<br>
> [0]PETSC ERROR: Configure options --PETSC_ARCH=arch-gxx-real --download-f-blas-lapack=1 --download-mpich=1 --with-cc=gcc --with-clanguage=C++ --with-cxx=g++ --with-dynamic-loading=1 --with-python=1 --with-scalar-type=real --with-shared-libraries=1<br>
> [0]PETSC ERROR: ------------------------------------------------------------------------<br>
> [0]PETSC ERROR: KSPSetUpNorms_Private() line 385 in /home/karpeev/petsc/dev/c/src/ksp/ksp/interface/itcreate.c<br>
> [0]PETSC ERROR: KSPSetFromOptions() line 409 in /home/karpeev/petsc/dev/c/src/ksp/ksp/interface/itcl.c<br>
> [0]PETSC ERROR: main() line 13 in ex.c<br>
> application called MPI_Abort(MPI_COMM_WORLD, 56) - process 0<br>
> [unset]: aborting job:<br>
> application called MPI_Abort(MPI_COMM_WORLD, 56) - process 0<br>
> [hal3 Tue Feb 26 09:37 PM] ~/petsc/dev/c/src/ksp/ksp/examples/tutorials/tmp ><br>
><br>
> The problem seems to be this clause in KSPSetUpNorms_Private():<br>
><br>
><br>
> if (ksp->normtype == KSP_NORM_DEFAULT && i == KSP_NORM_NONE && ksp->normsupporttable[i][j] <= 1) {<br>
> continue; /* Skip because we don't want to default to no norms unless set by the KSP (preonly). */<br>
><br>
><br>
> It is hit because of the code in KSPCreate_PREONLY() you quoted:<br>
><br>
> ierr = KSPSetSupportedNorm(ksp,KSP_NORM_NONE,PC_LEFT,2);CHKERRQ(ierr); /* LEFT/RIGHT is arbitrary, so "support" both */<br>
> ierr = KSPSetSupportedNorm(ksp,KSP_NORM_NONE,PC_RIGHT,1);CHKERRQ(ierr);<br>
><br>
> The problem is that PC_RIGHT is preferred by KSP_NORM only with priority 1, which is too weak to overcome<br>
> that "continue" clause above.<br>
<br>
</div></div> Ok, this is a bug, we'll leave it to Jed to fix properly since he created this Frankensteinen monster.<br></blockquote><div><br></div><div>Is increasing priority of PC_RIGHT to 2 in KSPPREONLY an option as an interim solution?</div>
<div>It would be nice to patch petsc-3.3 with it, since codes like Moose are likely to keep using it for a while.</div><div><br></div><div>Dmitry.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
><br>
> One way to fix it is to jack up the priority of PC_RIGHT, but I still don't understand why this combination<br>
> of norms and pc sides is being figured out in KSPSetFromOptions() (twice) with only partial KSP data.<br>
<br>
</div> Because it want's to give as reasonable a possible solution to the user before the user gets to override with something else.<br>
<div><div class="h5"><br>
> And then again, this time "for real", in KSPSetUp().<br>
><br>
> Dmitry.<br>
><br>
> On Wed, Feb 27, 2013 at 2:52 AM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> On Feb 26, 2013, at 4:44 PM, Dmitry Karpeev <<a href="mailto:karpeev@mcs.anl.gov">karpeev@mcs.anl.gov</a>> wrote:<br>
><br>
> > These calls compute default values for normtype and pcside based on partial KSP options,<br>
> > which can cause an unwarranted error to be thrown.<br>
> > For example, in code there may be<br>
> ><br>
> > KSPSetPCSide(ksp, PC_RIGHT); /* hardwired default, e.g., in Moose. */<br>
> ><br>
> > Now, when I'm using command-line arguments<br>
> > -ksp_type preonly<br>
> > an error is thrown, since KSPPREONLY doesn't work with PC_RIGHT.<br>
><br>
> Huh?<br>
><br>
> EXTERN_C_BEGIN<br>
> #undef __FUNCT__<br>
> #define __FUNCT__ "KSPCreate_PREONLY"<br>
> PetscErrorCode KSPCreate_PREONLY(KSP ksp)<br>
> {<br>
> PetscErrorCode ierr;<br>
><br>
> PetscFunctionBegin;<br>
> ierr = KSPSetSupportedNorm(ksp,KSP_NORM_NONE,PC_LEFT,2);CHKERRQ(ierr); /* LEFT/RIGHT is arbitrary, so "support" both */<br>
> ierr = KSPSetSupportedNorm(ksp,KSP_NORM_NONE,PC_RIGHT,1);CHKERRQ(ierr);<br>
><br>
> Is it because MOOSE also hardwires the norm type and preonly doesn't support it? What is the full and complete error message.<br>
><br>
> > Fine, I try<br>
> > -ksp_type preonly -ksp_pc_side left<br>
> > but still get the same error, since KSPSetUpNorms_Private() is called after KSP type has been set to KSPPREONLY,<br>
> > but BEFORE there was a chance to set the PC side!<br>
> ><br>
> > Is there any reason to keep these calls to KSPSetUpNorms_Private() in KSPSetFromOptions()?<br>
><br>
> I think they are there so that users can overwrite them in the rest of KSPSetFromOptions(). If you move them to KSPSetUp() then the user cannot reset them.<br>
><br>
> Barry<br>
><br>
><br>
> > KSPSetUpNorms_Private() will be just about the first thing called in KSPSetUp() and will compute the appropriate normtype and pcside,<br>
> > but now based on complete KSP options.<br>
> ><br>
> > Not to mention that calling XXXSetUp_YYY() XXXSetFromOptions() seems generally contrary to PETSc's design<br>
> > philosophy.<br>
> ><br>
> > Dmitry.<br>
> ><br>
> ><br>
><br>
><br>
><br>
><br>
</div></div>> <ex.c><makefile><br>
<br>
</blockquote></div><br><br>