[petsc-users] Reuse KSP

Young, Matthew, Adam may at bu.edu
Tue Apr 17 07:33:21 CDT 2018


My code (C/C++) uses PETSc to solve a linear system at each iteration in a time-stepping scheme. The PETSc routines are separated out because the scheme that uses them is optional in the larger code.


At each time step, the PETSc scheme calls a routine that includes:


{

  Mat A;

  Vec x,b;

  KSP ksp;


  [Set up A,x,b]


  KSPCreate(PETSC_COMM_WORLD,&ksp);


  [Build A and b from simulation data]


  [Set nullspace of A with MatSetNullSpace]


  KSPSetOperators(ksp,A,A);

  KSPSetFromOptions(ksp);

  KSPSolve(ksp,b,x);


  [Write x into an instance of our array class, perform checks, etc.]


  KSPDestroy(&ksp);


  return(0);

}


My question is: If I want to use superLU_DIST with the option -mat_superlu_dist_fact SamePattern (or SamePattern_SameRowPerm), should I move KSPCreate/Destroy outside of the time-step loop in the larger code?


Thanks.

----------------------------
Matthew Young
PhD Candidate
Astronomy Department
Boston University


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180417/c4dc7401/attachment.html>


More information about the petsc-users mailing list