[petsc-users] How to decompose and record a constant A

Smith, Barry F. bsmith at mcs.anl.gov
Tue Apr 9 16:19:03 CDT 2019



> On Apr 9, 2019, at 3:33 AM, Mark Adams via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> PETSc solvers will cache any setup computations, like a matrix factorization, and will reuse them on subsequent solves. 
> 
> If you call KSPSetOperators, PETSc will assume its cache is invalid and redo any required setup on subsequent solves.

    This is not actually correct; calling KSPSetOperators() again with the same matrix where you have not changed the matrix values will
not require any redo of the preconditioner setup.  KSP/PC/Mat tracks the current state of the matrix and rebuilds the preconditioner ONLY 
if you have changed the values of the matrix somehow (for example with new calls to MatSetValues, MatDiagonalSet etc). 

    Thus you can call KSPSetOperators() once with your matrix and make repeated calls to KSPSolve(), if the matrix is unchanged KSPSolve() will reuse the previously constructed preconditioner, if the matrix is changed PETSc will automatically redo the construction of the preconditioner.

   Barry

> 
> Mark
> 
> On Tue, Apr 9, 2019 at 4:08 AM ztdepyahoo via petsc-users <petsc-users at mcs.anl.gov> wrote:
> Dear group:
>       I need to solve a Laplacian problem Ax=b every time step where A is a constant . I want to store the inverse of A at the first time step. 
> how to do with Petsc
>  Regards
> 
>  	
> ztdepyahoo
> ztdepyahoo at gmail.com
> 签名由 网易邮箱大师 定制



More information about the petsc-users mailing list