petsc-3.7.1 2016-05-15
Report Typos and Errors

# KSPBuildSolution

Builds the approximate solution in a vector provided. This routine is NOT commonly needed (see KSPSolve()).

### Synopsis

    #include "petscksp.h"
    PetscErrorCode  KSPBuildSolution(KSP ksp,Vec v,Vec *V)

Collective on KSP Many br

### Input Parameter

ctx -iterative context obtained from KSPCreate() Many br

### Output Parameter

Provide exactly one of Many br

| v | - location to stash solution. Many br
| V | - the solution is returned in this location. This vector is created Many brinternally. This vector should NOT be destroyed by the user with Many brVecDestroy(). Many br

### Notes

This routine can be used in one of two ways Many br

          KSPBuildSolution(ksp,NULL,&V);
       or
          KSPBuildSolution(ksp,v,NULL); or KSPBuildSolution(ksp,v,&v);

Many brIn the first case an internal vector is allocated to store the solution Many br(the user cannot destroy this vector). In the second case the solution Many bris generated in the vector that the user provides. Note that for certain Many brmethods, such as KSPCG, the second case requires a copy of the solution, Many brwhile in the first case the call is essentially free since it simply Many brreturns the vector where the solution already is stored. For some methods Many brlike GMRES this is a reasonably expensive operation and should only be Many brused in truly needed. Many br

Many br

### Keywords

KSP, build, solution

### See Also

KSPGetSolution(), KSPBuildResidual()

Level:advanced
Location:src/ksp/ksp/interface/itfunc.c
Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/ksp/ksp/examples/tutorials/ex9.c.html
src/ksp/ksp/examples/tutorials/ex2f.F.html
src/snes/examples/tutorials/ex12.c.html