Skip to main content
`Ctrl`+`K`

# DMTS

Object held by a `DM` that contains all the callback functions and their contexts needed by a `TS`

## Synopsis

    typedef struct _p_DMTS *DMTS;

## Notes

Users provide callback functions and their contexts to `TS` using, for example, `TSSetIFunction()`. These values are stored in a `DMTS` that is contained in the `DM` associated with the `TS`. If no `DM` was provided by the user with `TSSetDM()` it is automatically created by `TSGetDM()` with `DMShellCreate()`.

Users very rarely need to worked directly with the `DMTS` object, rather they work with the `TS` and the `DM` they created

Multiple `DM` can share a single `DMTS`, often each `DM` is associated with a grid refinement level. `DMGetDMTS()` returns the `DMTS` associated with a `DM`. `DMGetDMTSWrite()` returns a unique `DMTS` that is only associated with the current `DM`, making a copy of the shared `DMTS` if needed (copy-on-write).

See `DMKSP` for details on why there is a needed for `DMTS` instead of simply storing the user callbacks directly in the `DM` or the `TS`

## Developer Note

The original `dm` inside the `DMTS` is NOT reference counted (to prevent a reference count loop between a `DM` and a `DMSNES`). The `DM` on which this context was first created is cached here to implement one-way copy-on-write. When `DMGetDMTSWrite()` sees a request using a different `DM`, it makes a copy of the `DMTS`.

## See Also

TS: Scalable ODE and DAE Solvers, `TSCreate()`, `DM`, `DMGetDMTSWrite()`, `DMGetDMTS()`, `TSSetIFunction()`, `DMTSSetRHSFunctionContextDestroy()`, `DMTSSetRHSJacobian()`, `DMTSGetRHSJacobian()`, `DMTSSetRHSJacobianContextDestroy()`, `DMTSSetIFunction()`, `DMTSGetIFunction()`, `DMTSSetIFunctionContextDestroy()`, `DMTSSetIJacobian()`, `DMTSGetIJacobian()`, `DMTSSetIJacobianContextDestroy()`, `DMTSSetI2Function()`, `DMTSGetI2Function()`, `DMTSSetI2FunctionContextDestroy()`, `DMTSSetI2Jacobian()`, `DMTSGetI2Jacobian()`, `DMTSSetI2JacobianContextDestroy()`, `DMKSP`, `DMSNES`

## Level

developer

## Location

include/petsc/private/tsimpl.h

## Implementations

_p_DMTS in include/petsc/private/tsimpl.h
DMTS_DA in src/ts/utils/dmdats.c
DMTS_Local in src/ts/utils/dmlocalts.c

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