[petsc-users] initial guess

Barry Smith bsmith at mcs.anl.gov
Sun Nov 30 11:48:41 CST 2014

   By default PETSc zeros x at the beginning of the linear solve*. If you call KSPSetInitialGuessNonzero() then PETSc does NOT zero x and uses whatever value is in x as the starting point. Note you cannot use both KSPSetInitialGuessKnoll() and KSPSetInitialGuessNonzero().

   Whether using some "previous" solution as an initial guess depends on the problem you are solving and how you are solving it. For example, if you are using Newton's Method then using the previous initial guess is just plain silly because Newton's method solves for the correction. In general if what you are doing requires a linear solve for a "correction" then using the nonzero initial guess is not the way to go.


* Unless you are using KSPSetInitialGuessKnoll() then it starts with xo = preconditioner (applied to) b

> On Nov 30, 2014, at 11:33 AM, UK <paulhuaizhang at uky.edu> wrote:
> Hello,
> I am using KSPFGMRES as my linear solver for Ax=b system. I was wondering how the initial guess will influence the computation efficiency. Does PETSc always starts with xo=0 or some value else? If I use my previous solution as the initial guess for current computation  is it going to take less effort for PETSc to solve the system? (my configuration attached)
> Thanks,
> Paul
>         MatCreateMPIAIJ(
>                         PETSC_COMM_WORLD,
>                         grid[gid].cellCount*nVars,
>                         grid[gid].cellCount*nVars,
>                         grid[gid].globalCellCount*nVars,
>                         grid[gid].globalCellCount*nVars,
>                         0,&diagonal_nonzeros[0],
>                         0,&off_diagonal_nonzeros[0],
>                         &impOP);
>         KSPSetOperators(ksp,impOP,impOP,SAME_NONZERO_PATTERN);
>         KSPSetTolerances(ksp,rtol,abstol,1.e15,maxits);
>         KSPSetInitialGuessKnoll(ksp,PETSC_TRUE);
>         KSPSetType(ksp,KSPFGMRES);
> Huaibao (Paul) Zhang
> Gas Surface Interactions Lab
> Department of Mechanical Engineering
> University of Kentucky,
> Lexington,
> KY, 40506-0503
> Office: 216 Ralph G. Anderson Building
> Web:gsil.engineering.uky.edu

More information about the petsc-users mailing list