This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to pass PETSc options to PETScSNESSolver?

0 votes

Dear community,

I'd like to set petsc command line options for my PETScSNESSolver. However, the options are not passed to the solver. MWE:

   args = """
      --petsc.snes_monitor
      --petsc.snes_atol 0.0
      --petsc.snes_max_it 10""".split()
   parameters.parse(args)
   solver = PETScSNESSolver()
   snes = solver.snes()
   snes.setFromOptions() 
   snes.getTolerances()

gives the default settings

   (1e-08, 1e-50, 1e-08, 50)

How does it work?

Thanks!
David

edit: Actually it seems to work. Though not very well with interactive IPython sessions; once set, the options cannot be changed. That was my mistake.

asked Jun 16, 2016 by dajuno FEniCS User (4,140 points)
edited Jun 16, 2016 by dajuno

1 Answer

+1 vote
 
Best answer

You can also use PETScOptions, e.g.

PETScOptions().set("snes_monitor")
PETScOptions().set("snes_max_it", 10)
answered Jun 16, 2016 by Magne Nordaas FEniCS Expert (13,820 points)
selected Jun 16, 2016 by dajuno

Great, this is much more comfortable :)
Thanks!

...