:orphan:
# PetscObjectComposeFunction
Associates a function with a given PETSc object. 
## Synopsis
```
#include <petscsys.h>
PetscErrorCode PetscObjectComposeFunction(PetscObject obj, const char name[], void (*fptr)(void))
```
Logically Collective


## Input Parameters

- ***obj -*** the PETSc object; this must be cast with a (`PetscObject`), for example,
`PetscObjectCompose`((`PetscObject`)mat,...);
- ***name -*** name associated with the child function
- ***fptr -*** function pointer





## Notes
When the first argument of `fptr` is (or is derived from) a `PetscObject` then `PetscTryMethod()` and `PetscUseMethod()`
can be used to call the function directly with error checking.

To remove a registered routine, pass in `NULL` for `fptr`.

`PetscObjectComposeFunction()` can be used with any PETSc object (such as
`Mat`, `Vec`, `KSP`, `SNES`, etc.) or any user-provided object.

`PetscUseTypeMethod()` and `PetscTryTypeMethod()` are used to call a function that is stored in the objects `obj->ops` table.


## See Also
 `PetscObjectQueryFunction()`, `PetscContainerCreate()` `PetscObjectCompose()`, `PetscObjectQuery()`, `PetscTryMethod()`, `PetscUseMethod()`,
`PetscUseTypeMethod()`, `PetscTryTypeMethod()`, `PetscObject`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/objects/inherit.c.html#PetscObjectComposeFunction">src/sys/objects/inherit.c</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex73.c.html">src/ksp/ksp/tutorials/ex73.c</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/tutorials/ex8.c.html">src/mat/tutorials/ex8.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/objects/inherit.c)


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