Skip to main content
`Ctrl`+`K`

# TSSetResize

Sets the resize callbacks.

## Synopsis

    #include "petscts.h"
    PetscErrorCode TSSetResize(TS ts, PetscBool rollback, PetscErrorCode (*setup)(TS ts, PetscInt step, PetscReal time, Vec state, PetscBool *resize, PetscCtx ctx), PetscErrorCode (*transfer)(TS ts, PetscInt nv, Vec vecsin[], Vec vecsout[], PetscCtx ctx), PetscCtx ctx)

Logically Collective

## Input Parameters

- ts - The `TS` context obtained from `TSCreate()`

- rollback - Whether a resize will restart the step

- setup - The setup function

- transfer - The transfer function

- ctx - [optional] The user-defined context

## Calling sequence of `setup`

- ts - the `TS` context

- step - the current step

- time - the current time

- state - the current vector of state

- resize - (output parameter) `PETSC_TRUE` if need resizing, `PETSC_FALSE` otherwise

- ctx - user defined context

## Calling sequence of `transfer`

- ts - the `TS` context

- nv - the number of vectors to be transferred

- vecsin - array of vectors to be transferred

- vecsout - array of transferred vectors

- ctx - user defined context

## Notes

The `setup` function is called inside `TSSolve()` after `TSEventHandler()` or after `TSPostStep()` depending on the `rollback` value: if `rollback` is true, then these callbacks behave as error indicators and will flag the need to remesh and restart the current step. Otherwise, they will simply flag the solver that the size of the discrete problem has changed. In both cases, the solver will collect the needed vectors that will be transferred from the old to the new sizes using the `transfer` callback. These vectors will include the current solution vector, and other vectors needed by the specific solver used. For example, `TSBDF` uses previous solutions vectors to solve for the next time step. Other application specific objects associated with the solver, i.e. Jacobian matrices and `DM`, will be automatically reset if the sizes are changed and they must be specified again by the user inside the `transfer` function. The input and output arrays passed to `transfer` are allocated by PETSc. Vectors in `vecsout` must be created by the user. Ownership of vectors in `vecsout` is transferred to PETSc.

## See Also

TS: Scalable ODE and DAE Solvers, `TS`, `TSSetDM()`, `TSSetIJacobian()`, `TSSetRHSJacobian()`

## Level

advanced

## Location

src/ts/interface/ts.c

## Examples

src/ts/tutorials/ex30.c
src/ts/tutorials/ex45.c
src/ts/tutorials/ex11.c

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