KSPMonitorSet and KSPMonitorCancel

Dear FreeFem users,

I would like to try out PCSHELL and MatShell (using func in FreeFem) to accelerate the solution of my problem. Everything seems to work as I wanted except for monitoring the solution. I want to monitor the outer KSPSolve, but not the ones inside the preconditioner func. The key part of the solution procedure is changing the parameters of the matrices inside the preconditioner function, which oddly turns on monitoring for the KSPSolve calls inside the preconditioner. The following MWE demonstrated the behaviour: is lines 46-51 are commented out, only the outer KSP call is monitored, while leaving the in the code each KSPSolve uses the monitor. Any ideas what causes this behaviour/how can it be circumwent?

diffusion-2d-PETSc-FieldSplit-PCSHELL.edp (2.1 KB)

You are not using any sort of prefix, making things hard to figure out.
If you replace your set(A, sparams = "..."); by something along these lines:

[...]
set(A, sparams = "-inner_ksp_type preonly -inner_pc_type lu -inner_ksp_reuse_preconditioner false -inner_ksp_monitor_cancel ", prefix = "inner_");
[...]
        set(A, sparams = "-inner_ksp_type preonly -inner_pc_type lu -inner_ksp_reuse_preconditioner true ", prefix="inner_");
[...]

Does it fix your issue?

1 Like

Thanks for the quick reply. Using prefixes results in the desired behavior!