Hi Henrik, On 23/03/17 13:47, Buesing, Henrik wrote:
Dear all,
PETSc options „-options_left“ and „-log_view“ seem to have no effect when setting as solver_parameters. I can prescribe them from the command line, but then I do not get the Firedrake/PETSc “options_left”.
How can I print the Firedrake/PETSc options_left. Thank you!
You need to pass "-log_view" as a commandline option, because by default, all options inside solver_parameters are prefixed by a custom prefix (so that solvers do not interfere with each other). You can set the options prefix for each solver individually using the options_prefix keyword argument (that allows you to control the solver options from the command line easily). However, so that we do not overflow the (static size) PETSc options database, the way we work with options is as follows: You say: solve(..., solver_parameters={...}) We insert the specified options into the options database, call setFromOptions on the PETSc KSP/SNES, call KSP/SNESSolve and then remove the options from the options database. Therefore, PETSc never sees any options in the database at the end of the program, so -options_left doesn't report anything. If you treat Firedrake solvers like PETSc ones and always set an options_prefix and only ever control them via options from the command-line, the -options_left will work: e.g. from firedrake import * mesh = UnitSquareMesh(1, 1) V = FunctionSpace(mesh, 'DG', 0) u = TrialFunction(V) v = TestFunction(V) a = u*v*dx L = v*dx u = Function(V) solve(a == L, u, options_prefix="") and then: $ python foo.py -options_left -ksp_type cg -pc_fieldsplit_type additive #PETSc Option Table entries: -ksp_type cg -options_left -pc_fieldsplit_type additive #End of PETSc Option Table entries There is one unused database option. It is: Option left: name:-pc_fieldsplit_type value: additive However, if you set that same option via the solver_parameters: from firedrake import * mesh = UnitSquareMesh(1, 1) V = FunctionSpace(mesh, 'DG', 0) u = TrialFunction(V) v = TestFunction(V) a = u*v*dx L = v*dx u = Function(V) solve(a == L, u, options_prefix="", solver_parameters={"pc_fieldsplit_type": "additive"}) $ python bar.py -options_left -ksp_type cg #PETSc Option Table entries: -ksp_type cg -options_left #End of PETSc Option Table entries There are no unused options. So you can see that PETSc doesn't even think, when the program exits, that pc_fieldsplit_type is in the options database, hence it is not an unused option. It might be possible to programmatically query the options database inside the solve call to see what options have been used, but I'm not sure. Lawrence