petsc-3.7.1 2016-05-15
Report Typos and Errors

TSSetEventHandler

Sets a monitoring function used for detecting events

Synopsis

#include "petscts.h" 
PetscErrorCode TSSetEventHandler(TS ts,PetscInt nevents,PetscInt direction[],PetscBool terminate[],PetscErrorCode (*eventhandler)(TS,PetscReal,Vec,PetscScalar[],void*),PetscErrorCode (*postevent)(TS,PetscInt,PetscInt[],PetscReal,Vec,PetscBool,void*),void *ctx)
Logically Collective on TS Many br

Input Parameters

ts - the TS context obtained from TSCreate() Many br
nevents - number of local events Many br
direction - direction of zero crossing to be detected. -1 => Zero crossing in negative direction, Many br+1 => Zero crossing in positive direction, 0 => both ways (one for each event) Many br
terminate - flag to indicate whether time stepping should be terminated after Many brevent is detected (one for each event) Many br
eventhandler - event monitoring routine Many br
postevent - [optional] post-event function Many br
ctx - [optional] user-defined context for private data for the Many brevent monitor and post event routine (use NULL if no Many brcontext is desired) Many br

Calling sequence of eventhandler

PetscErrorCode EventHandler(TS ts,PetscReal t,Vec U,PetscScalar fvalue[],void* ctx) Many br

Input Parameters

ts - the TS context Many br
t - current time Many br
U - current iterate Many br
ctx - [optional] context passed with eventhandler Many br

Output parameters

fvalue -function value of events at time t Many br

Calling sequence of postevent

PetscErrorCode PostEvent(TS ts,PetscInt nevents_zero,PetscInt events_zero[],PetscReal t,Vec U,PetscBool forwardsolve,void* ctx) Many br

Input Parameters

ts - the TS context Many br
nevents_zero - number of local events whose event function is zero Many br
events_zero - indices of local events which have reached zero Many br
t - current time Many br
U - current solution Many br
forwardsolve - Flag to indicate whether TS is doing a forward solve (1) or adjoint solve (0) Many br
ctx - the context passed with eventhandler Many br

Many br

Keywords

TS, event, set

See Also

TSCreate(), TSSetTimeStep(), TSSetConvergedReason()

Level:intermediate
Location:
src/ts/event/tsevent.c
Index of all TS routines
Table of Contents for all manual pages
Index of all manual pages

Examples

src/ts/examples/tutorials/ex40.c.html
src/ts/examples/tutorials/ex41.c.html