<div dir="ltr">Thanks again Barry. I figured it out. My SNESView was called before SNESSetFromOptions and hence was showing the default value. <div><br></div><div>Regards,</div><div>Bikash</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 14, 2018 at 11:28 PM, Smith, Barry F. <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"><br>
I stuck the line<br>
<br>
PetscOptionsSetValue(NULL,"-<wbr>snes_qn_m", "50");<br>
<br>
in src/snes/examples/tutorials/<wbr>ex19.c<br>
<br>
and called it with<br>
<br>
-da_refine 2 -snes_monitor -snes_type qn -snes_view<br>
<br>
and the results showed<br>
<br>
Stored subspace size: 50<br>
<br>
so I am afraid it is something unique to exactly your code that is causing it to be not used. If you can send us a complete code that reproduces the problem we can track it down and fix it but without a reproducing code we can't do anything to resolve the problem.<br>
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
> On Feb 14, 2018, at 9:15 PM, Bikash Kanungo <<a href="mailto:bikash@umich.edu">bikash@umich.edu</a>> wrote:<br>
><br>
> Thanks Barry and Matthew.<br>
><br>
> @Barry: I'm following the same procedure as you've mentioned - PetscOptionsSetValue() precede SNESSetFromOptions. Here's the snippet for my code:<br>
><br>
> ------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>-----------------<br>
><br>
> error = SNESCreate(PETSC_COMM_WORLD,&<wbr>snes);<br>
> checkPETScError(error,<br>
> "SNESCreate failed.");<br>
><br>
> error = SNESSetType(snes, SNESQN);<br>
> checkPETScError(error,<br>
> "SNESSetType failed.");<br>
><br>
> error = SNESQNSetType(snes, SNES_QN_LBFGS);<br>
> checkPETScError(error,<br>
> "SNESQNSetType failed.");<br>
><br>
> error = SNESQNSetScaleType(snes, SNES_QN_SCALE_SHANNO);<br>
> checkPETScError(error,<br>
> "SNESQNSetScaleType failed.");<br>
><br>
> error = SNESQNSetRestartType(snes, SNES_QN_RESTART_PERIODIC);<br>
> checkPETScError(error,<br>
> "SNESQNSetRestartType failed.");<br>
><br>
> error = PetscOptionsSetValue("-snes_<wbr>qn_m","500");<br>
> checkPETScError(error,<br>
> "PETScOptionsSetValue failed.");<br>
><br>
> SNESLineSearch linesearch;<br>
> error = SNESGetLineSearch(snes,&<wbr>linesearch);<br>
> checkPETScError(error,<br>
> "SNESGetLineSearch failed.");<br>
><br>
> error = SNESLineSearchSetType(<wbr>linesearch,SNESLINESEARCHCP);<br>
> checkPETScError(error,<br>
> "SNESLineSearchSetType failed.");<br>
><br>
> error = PetscOptionsSetValue("-snes_<wbr>linesearch_max_it", "1");<br>
> checkPETScError(error,<br>
> "PetscOptionsSetValue failed.");<br>
><br>
> error = SNESLineSearchView(linesearch, PETSC_VIEWER_STDOUT_WORLD);<br>
> checkPETScError(error,<br>
> "SNESLineSearchView failed.");<br>
><br>
> error =SNESLineSearchSetMonitor(<wbr>linesearch,<br>
> PETSC_TRUE);<br>
> checkPETScError(error,<br>
> "SNESLineSearchSet Monitor failed.");<br>
><br>
> error = SNESLineSearchSetFromOptions(<wbr>linesearch);<br>
> checkPETScError(error,<br>
> "SNESLineSearchSetFromOptions failed.");<br>
><br>
> SNESLineSearchReason lineSearchReason;<br>
> error = SNESLineSearchGetReason(<wbr>linesearch, &lineSearchReason);<br>
> checkPETScError(error,<br>
> "SNESLineSearchGetReason failed.");<br>
><br>
> error = SNESSetFunction(snes,r,<wbr>FormFunction,&petscData);<br>
> checkPETScError(error,<br>
> "SNESSetFunction failed.");<br>
><br>
> //<br>
> // Customize KSP<br>
> //<br>
> error = SNESGetKSP(snes,&ksp);<br>
> checkPETScError(error,<br>
> "SNESGetKSP failed.");<br>
><br>
> error = KSPSetType(ksp,KSPGMRES);<br>
> checkPETScError(error,<br>
> "KSPSetType failed.");<br>
><br>
> error = KSPGMRESSetRestart(ksp,300);<br>
> checkPETScError(error,<br>
> "KSPGMRESSetRestart failed.");<br>
><br>
> error = KSPSetInitialGuessNonzero(ksp,<wbr>PETSC_TRUE);<br>
> checkPETScError(error,<br>
> "KSPSetInitialGuessNonzero failed.");<br>
><br>
> error = KSPGetPC(ksp,&pc);<br>
> checkPETScError(error,<br>
> "KSPGetPC failed.");<br>
><br>
> error = PCSetType(pc,PCJACOBI);<br>
> checkPETScError(error,<br>
> "PCSetType failed.");<br>
><br>
> error = PCSetReusePreconditioner(pc,<wbr>PETSC_TRUE);<br>
> checkPETScError(error,<br>
> "PCSetReusePreconditioner failed.");<br>
><br>
> error = KSPSetTolerances(ksp,<br>
> PETSC_DEFAULT,<br>
> 1e-15,<br>
> 1e7,<br>
> 10000);<br>
> checkPETScError(error,<br>
> "KSPSetTolerances failed.");<br>
><br>
> error = KSPSetFromOptions(ksp);<br>
> checkPETScError(error,<br>
> "Call to KSPSetFromOptions() failed.");<br>
><br>
> //<br>
> //get reason for non-convergence<br>
> //<br>
> KSPConvergedReason kspReason;<br>
> error = KSPGetConvergedReason(ksp, &kspReason);<br>
> checkPETScError(error,<br>
> "Call to KSPGetConvergedReason() failed.");<br>
><br>
> if(kspReason < 0)<br>
> {<br>
> if(debugLevel != 0)<br>
> std::cout<<"Other kind of divergence in SNES-KSP : "<< kspReason <<std::endl;<br>
><br>
> }<br>
><br>
> PetscInt lag = 1;<br>
> error = SNESSetLagPreconditioner(snes,<br>
> lag);<br>
> checkPETScError(error,<br>
> "Call to SNESSetLagPreconditioner() failed.");<br>
><br>
> PetscInt maxFails = 2;<br>
> error = SNESSetMaxLinearSolveFailures(<wbr>snes,maxFails);<br>
> checkPETScError(error,<br>
> "Call to SNESSetMaxLinearSolveFailures(<wbr>) failed.");<br>
><br>
> PetscReal abstol = 1e-13; // absolute convergence tolerance<br>
> PetscInt maxit = 100000;<br>
> error = SNESSetTolerances(snes,<br>
> abstol,<br>
> PETSC_DEFAULT,<br>
> PETSC_DEFAULT,<br>
> maxit,<br>
> maxit);<br>
> checkPETScError(error,<br>
> "SNESSetTolerances failed.");<br>
><br>
> error = SNESView(snes,<br>
> PETSC_VIEWER_STDOUT_WORLD);<br>
> checkPETScError(error,<br>
> "Call to SNESView() failed.");<br>
><br>
> error = SNESMonitorSet(snes,<wbr>SNESMonitorDefault,PETSC_NULL,<wbr>PETSC_NULL);<br>
> checkPETScError(error,<br>
> "Call to SNESMonitorSet() failed.");<br>
><br>
> error = SNESSetFromOptions(snes);<br>
> checkPETScError(error,<br>
> "Call to SNESSetFromOptions() failed.");<br>
><br>
><br>
> //<br>
> // Solve the system<br>
> //<br>
> error = SNESSolve(snes,PETSC_NULL,x);<br>
> checkPETScError(error,<br>
> "Call to SNESSolve() failed.");<br>
><br>
> SNESConvergedReason reason;<br>
> error = SNESGetConvergedReason(snes,&<wbr>reason);<br>
> checkPETScError(error,<br>
> "Call to SNESGetConvergedReason() failed.");<br>
><br>
> ------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------------<br>
><br>
> Also, I didn't find any SNESQN examples in my snes/examples folder (using petsc-3.6.3).<br>
> Moreover, the Powell descent condition seems to be only declared and then assigned a value through the PetscOptionsReal call. Beyond that I didn't find any other mention of it. I was grepping for powell_downhill variable. (Note: powell_downhill features in 3.6.3 and not in 3.7 version).<br>
><br>
> Thanks,<br>
> Bikash<br>
><br>
><br>
> On Wed, Feb 14, 2018 at 7:02 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
> On Wed, Feb 14, 2018 at 6:43 PM, Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> Hmm,<br>
><br>
> 1) make sure you call PetscOptionsSetValue() before you call to SNESSetFromOptions()<br>
><br>
> 2) make sure you call SNESSetFromOptions()<br>
><br>
> 3) did you add a prefix to the SNES object? If so make sure you include it in the PetscOptionsSetValue() call.<br>
><br>
> I can't see a reason why it won't work. Does it work with the PETSc examples for you or not?<br>
><br>
> Regarding the Powell descent option, I'm afraid you'll need to examine the code for exact details. src/snes/impls/qn/qn.c<br>
><br>
> Here is the description<br>
><br>
> <a href="https://bitbucket.org/petsc/petsc/src/939b553f045c5ba32242d0d49e80e4934ed3bf76/src/snes/impls/qn/qn.c?at=master&fileviewer=file-view-default#qn.c-451" rel="noreferrer" target="_blank">https://bitbucket.org/petsc/<wbr>petsc/src/<wbr>939b553f045c5ba32242d0d49e80e4<wbr>934ed3bf76/src/snes/impls/qn/<wbr>qn.c?at=master&fileviewer=<wbr>file-view-default#qn.c-451</a><br>
><br>
> Thanks,<br>
><br>
> Matt<br>
><br>
><br>
> Barry<br>
><br>
><br>
> > On Feb 14, 2018, at 5:25 PM, Bikash Kanungo <<a href="mailto:bikash@umich.edu">bikash@umich.edu</a>> wrote:<br>
> ><br>
> > Hi,<br>
> ><br>
> > I'm using the L-BFGS QN solver. In order to set the number of past states (also the restart size if I use Periodic restart), to say 50, I'm using PetscOptionsSetValue("-snes_<wbr>qn_m", "50"). However while running, it still shows "Stored subspace size: 10", i.e., the default value of 10 is not overwritten.<br>
> ><br>
> > Additionally, I would like to know more about the the -snes_qn_powell_descent option. For Powell restart, one uses a gamma parameter which I believe is defined by the -snes_qn_powell_gamma option. What exactly does the descent condition do? It would be useful if there are good references to it.<br>
> ><br>
> > Thanks,<br>
> > Biksah<br>
> ><br>
> > --<br>
> > Bikash S. Kanungo<br>
> > PhD Student<br>
> > Computational Materials Physics Group<br>
> > Mechanical Engineering<br>
> > University of Michigan<br>
> ><br>
><br>
><br>
><br>
><br>
> --<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<br>
><br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~<wbr>knepley/</a><br>
><br>
><br>
><br>
> --<br>
> Bikash S. Kanungo<br>
> PhD Student<br>
> Computational Materials Physics Group<br>
> Mechanical Engineering<br>
> University of Michigan<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><div><div><font color="#666666">Bikash S. Kanungo<br></font></div><font color="#666666">PhD Student<br></font></div><font color="#666666">Computational Materials Physics Group<br></font></div><font color="#666666">Mechanical Engineering <br></font></div><font color="#666666">University of Michigan<br><br></font></div></div>
</div>