4

What I did is

  1. Create some PC named pc, and PCSetOperators(pc,A,A,..);
  2. Create KSP named ksp;
  3. KSPSetPC(ksp,pc);

After the above process, am I still obliged to KSPSetOperators(ksp,A,A,..), or I can skip this? From the source code of Petsc, it seems I do not need. Just want to make sure.

Thanks!

Hui Zhang
  • 1,319
  • 7
  • 16

1 Answers1

4

While not strictly necessary in certain use cases, please call KSPSetOperators() anyway (perhaps instead of PCSetOperators()). This ensures that null space and setup information is consistent and manages initial guesses for repeated solution of linear systems ("Fischer guess"). Calling KSPSetOperators() with the same operators is essentially free.

Note that you can always KSPGetPC() and then configure the PC, instead of creating it yourself and using KSPSetPC().

Jed Brown
  • 25,650
  • 3
  • 72
  • 130