Passing "None" to solver does not work

Issue #127 resolved
Miguel Arriaga created an issue

I’m trying to implement a python version of the PETSc example in ksp/ex25 [https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex25.c.html]

Unfortunately, there is line there that as far as I know has no equivalent in petsc4py, namely

KSPSolve(ksp,NULL,NULL);

if I try to use ksp.solve(None,None) I get the error:

TypeError: Argument 'b' has incorrect type (expected petsc4py.PETSc.Vec, got NoneType)

I imagined that this solve step was a way to force the ksp to set itself up and so I tried to replace the line with

ksp.setUp()

This worked when I just ran without any options. However, when I run the script with the options that they suggest:

python3 ex25.py -pc_type mg -ksp_type fgmres -da_refine 2 -ksp_monitor_short -mg_levels_ksp_monitor_short -mg_levels_ksp_norm_type unpreconditioned -ksp_view -pc_mg_type full

I get the error Local index 128 too large 127 (max) at 0

Is KSPSolve(ksp,NULL,NULL); doing something else than ksp.setUp()? If yes, how can we achieve that behavior in petsc4py since ksp.solve(None,None) does not work?

Comments (2)

  1. Log in to comment