Hello, I have a (hopefully) quick question about setting the restart for gmres. I set the restart to be 50, but when I use KSPView it looks like GMRES still uses a restart of 30. It is possible that I overwrite my settings somehow? Here is the relevant part of my code: KSPCreate(PETSC_COMM_WORLD,&ksp); KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN); KSPGMRESSetRestart(ksp,50); KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); KSPSetTolerances(ksp,1.e-12,1.e-12,PETSC_DEFAULT,100000); KSPSetUp(ksp); KSPGetPC(ksp,&pc); PCSetType(pc,PCNONE); KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); KSPSolve(ksp,b,x); Thanks, Verena
On Nov 29, 2010, at 5:04 PM, Verena Kuhlemann wrote:
Hello,
I have a (hopefully) quick question about setting the restart for gmres.
I set the restart to be 50, but when I use KSPView it looks like GMRES still uses a restart of 30. It is possible that I overwrite my settings somehow? Here is the relevant part of my code:
KSPCreate(PETSC_COMM_WORLD,&ksp); KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);
KSPSetType(ksp,KSPGMRES);
KSPGMRESSetRestart(ksp,50);
You have not set the type to GMRES by this point, therefor the setting of restart is ignored. Must set the type before this. BTW: we highly recommend just calling KSPSetFromOptions() and setting parameters from the options database, much nicer IOHO then hardwiring in the source code. Barry
KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); KSPSetTolerances(ksp,1.e-12,1.e-12,PETSC_DEFAULT,100000); KSPSetUp(ksp); KSPGetPC(ksp,&pc); PCSetType(pc,PCNONE); KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); KSPSolve(ksp,b,x);
Thanks, Verena
On Mon, Nov 29, 2010 at 6:08 PM, Barry Smith <[email protected]> wrote:
On Nov 29, 2010, at 5:04 PM, Verena Kuhlemann wrote:
Hello,
I have a (hopefully) quick question about setting the restart for gmres.
I set the restart to be 50, but when I use KSPView it looks like GMRES still uses a restart of 30. It is possible that I overwrite my settings somehow? Here is the relevant part of my code:
KSPCreate(PETSC_COMM_WORLD,&ksp); KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);
KSPSetType(ksp,KSPGMRES);
KSPGMRESSetRestart(ksp,50);
You have not set the type to GMRES by this point, therefor the setting of restart is ignored. Must set the type before this.
Ah, I thought I don't have to set it, since GMRES is the default. Now it works, thanks.
BTW: we highly recommend just calling KSPSetFromOptions() and setting parameters from the options database, much nicer IOHO then hardwiring in the source code.
Barry
KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); KSPSetTolerances(ksp,1.e-12,1.e-12,PETSC_DEFAULT,100000); KSPSetUp(ksp); KSPGetPC(ksp,&pc); PCSetType(pc,PCNONE); KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); KSPSolve(ksp,b,x);
Thanks, Verena
-- Verena Kuhlemann Ph.D. Candidate Mathematics and Computer Science Department Emory University
On Nov 29, 2010, at 6:01 PM, Verena Kuhlemann wrote:
On Mon, Nov 29, 2010 at 6:08 PM, Barry Smith <[email protected]> wrote:
On Nov 29, 2010, at 5:04 PM, Verena Kuhlemann wrote:
Hello,
I have a (hopefully) quick question about setting the restart for gmres.
I set the restart to be 50, but when I use KSPView it looks like GMRES still uses a restart of 30. It is possible that I overwrite my settings somehow? Here is the relevant part of my code:
KSPCreate(PETSC_COMM_WORLD,&ksp); KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN);
KSPSetType(ksp,KSPGMRES);
KSPGMRESSetRestart(ksp,50);
You have not set the type to GMRES by this point, therefor the setting of restart is ignored. Must set the type before this.
Ah, I thought I don't have to set it, since GMRES is the default. Now it works, thanks.
The thing is it delays picking the default as long as possible, thus it was not set at that point. But you are right, it would be reasonable to be known the whole time. Barry
BTW: we highly recommend just calling KSPSetFromOptions() and setting parameters from the options database, much nicer IOHO then hardwiring in the source code.
Barry
KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); KSPSetTolerances(ksp,1.e-12,1.e-12,PETSC_DEFAULT,100000); KSPSetUp(ksp); KSPGetPC(ksp,&pc); PCSetType(pc,PCNONE); KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); KSPSolve(ksp,b,x);
Thanks, Verena
-- Verena Kuhlemann Ph.D. Candidate Mathematics and Computer Science Department Emory University
On Mon, Nov 29, 2010 at 5:04 PM, Verena Kuhlemann <[email protected]> wrote:
Hello,
I have a (hopefully) quick question about setting the restart for gmres.
I set the restart to be 50, but when I use KSPView it looks like GMRES still uses a restart of 30. It is possible that I overwrite my settings somehow? Here is the relevant part of my code:
KSPCreate(PETSC_COMM_WORLD,&ksp); KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN); KSPGMRESSetRestart(ksp,50);
This is ignored because you have not yet set the KSP type.
KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); KSPSetTolerances(ksp,1.e-12,1.e-12,PETSC_DEFAULT,100000); KSPSetUp(ksp);
If you move this before the restart call, the type wil be set and it will work. Matt
KSPGetPC(ksp,&pc); PCSetType(pc,PCNONE); KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); KSPSolve(ksp,b,x);
Thanks, Verena
-- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener
participants (3)
-
Barry Smith -
Matthew Knepley -
Verena Kuhlemann