Skip to main content
`Ctrl`+`K`

# KSPSetApplicationContext

Sets the optional user-defined context for the linear solver.

## Synopsis

    #include "petscksp.h"
    PetscErrorCode KSPSetApplicationContext(KSP ksp, void *ctx)

Logically Collective

## Input Parameters

- ksp - the `KSP` context

- ctx - user context

## Notes

The user context is a way for users to attach any information to the `KSP` that they may need later when interacting with the `KSP`

Use `KSPGetApplicationContext()` to get access to the context at a later time.

## Fortran Note

This only works when `ctx` is a Fortran derived type (it cannot be a `PetscObject`), we recommend writing a Fortran interface definition for this function that tells the Fortran compiler the derived data type that is passed in as the `ctx` argument. See `KSPGetApplicationContext()` for an example.

## See Also

KSP: Linear System Solvers, `KSP`, `KSPGetApplicationContext()`

## Level

intermediate

## Location

src/ksp/ksp/interface/iterativ.c

Index of all KSP routines
Table of Contents for all manual pages
Index of all manual pages