4
$\begingroup$

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!

$\endgroup$
4
$\begingroup$

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().

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.