# PCShellSetPreSolve
Sets routine to apply to the operators/vectors before a `KSPSolve()` is applied. This usually does something like scale the linear system in some application specific way. 
## Synopsis
```
#include "petscpc.h" 
PetscErrorCode PCShellSetPreSolve(PC pc, PetscErrorCode (*presolve)(PC, KSP, Vec, Vec))
```
Logically Collective


## Input Parameters

- ***pc -*** the preconditioner context
- ***presolve -*** the application-provided presolve routine



## Calling sequence of presolve
```none
   PetscErrorCode presolve (PC,KSP ksp,Vec b,Vec x)
```



- ***pc -*** the preconditioner, get the application context with PCShellGetContext()
- ***xin -*** input vector
- ***xout -*** output vector



## Note
The function MUST return an error code of 0 on success and nonzero on failure.




## See Also
 `PCSHELL`, `PCShellSetApplyRichardson()`, `PCShellSetSetUp()`, `PCShellSetApplyTranspose()`, `PCShellSetPostSolve()`, `PCShellSetContext()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/impls/shell/shellpc.c.html#PCShellSetPreSolve">src/ksp/pc/impls/shell/shellpc.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/pc/impls/shell/shellpc.c.html#PCShellSetPreSolve_Shell(PC pc, PetscErrorCode (*presolve)">PCShellSetPreSolve_Shell(PC pc, PetscErrorCode (*presolve) in src/ksp/pc/impls/shell/shellpc.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/ksp/pc/impls/shell/shellpc.c)


[Index of all PC routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
