1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML3.2 EN">
<HTML>
<HEAD> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetEventHandler.html" />
<META NAME="GENERATOR" CONTENT="DOCTEXT">
<TITLE>TSSetEventHandler</TITLE>
</HEAD>
<BODY BGCOLOR="FFFFFF">
<div id="version" align=right><b>petsc-3.7.5 2017-01-01</b></div>
<div id="bugreport" align=right><a href="mailto:petsc-maint@mcs.anl.gov?subject=Typo or Error in Documentation &body=Please describe the typo or error in the documentation: petsc-3.7.5 v3.7.5 docs/manualpages/TS/TSSetEventHandler.html "><small>Report Typos and Errors</small></a></div>
<A NAME="TSSetEventHandler"><H1>TSSetEventHandler</H1></A>
Sets a monitoring function used for detecting events
<H3><FONT COLOR="#CC3333">Synopsis</FONT></H3>
<PRE>
#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)
</PRE>
Logically Collective on <A HREF="../TS/TS.html#TS">TS</A>
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ts </B></TD><TD>- the <A HREF="../TS/TS.html#TS">TS</A> context obtained from <A HREF="../TS/TSCreate.html#TSCreate">TSCreate</A>()
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>nevents </B></TD><TD>- number of local events
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>direction </B></TD><TD>- direction of zero crossing to be detected. -1 => Zero crossing in negative direction,
+1 => Zero crossing in positive direction, 0 => both ways (one for each event)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>terminate </B></TD><TD>- flag to indicate whether time stepping should be terminated after
event is detected (one for each event)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>eventhandler </B></TD><TD>- event monitoring routine
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>postevent </B></TD><TD>- [optional] post-event function
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- [optional] user-defined context for private data for the
event monitor and post event routine (use NULL if no
context is desired)
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Calling sequence of eventhandler</FONT></H3>
<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> EventHandler(<A HREF="../TS/TS.html#TS">TS</A> ts,<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A> t,<A HREF="../Vec/Vec.html#Vec">Vec</A> U,<A HREF="../Sys/PetscScalar.html#PetscScalar">PetscScalar</A> fvalue[],void* ctx)
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ts </B></TD><TD>- the <A HREF="../TS/TS.html#TS">TS</A> context
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>t </B></TD><TD>- current time
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>U </B></TD><TD>- current iterate
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- [optional] context passed with eventhandler
</TD></TR></TABLE>
<P>
<H3><FONT COLOR="#CC3333">Output parameters</FONT></H3>
<DT><B>fvalue </B> -function value of events at time t
<br>
<P>
<H3><FONT COLOR="#CC3333">Calling sequence of postevent</FONT></H3>
<A HREF="../Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PostEvent(<A HREF="../TS/TS.html#TS">TS</A> ts,<A HREF="../Sys/PetscInt.html#PetscInt">PetscInt</A> nevents_zero,<A HREF="../Sys/PetscInt.html#PetscInt">PetscInt</A> events_zero[],<A HREF="../Sys/PetscReal.html#PetscReal">PetscReal</A> t,<A HREF="../Vec/Vec.html#Vec">Vec</A> U,<A HREF="../Sys/PetscBool.html#PetscBool">PetscBool</A> forwardsolve,void* ctx)
<P>
<H3><FONT COLOR="#CC3333">Input Parameters</FONT></H3>
<TABLE border="0" cellpadding="0" cellspacing="0">
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ts </B></TD><TD>- the <A HREF="../TS/TS.html#TS">TS</A> context
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>nevents_zero </B></TD><TD>- number of local events whose event function is zero
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>events_zero </B></TD><TD>- indices of local events which have reached zero
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>t </B></TD><TD>- current time
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>U </B></TD><TD>- current solution
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>forwardsolve </B></TD><TD>- Flag to indicate whether <A HREF="../TS/TS.html#TS">TS</A> is doing a forward solve (1) or adjoint solve (0)
</TD></TR>
<TR><TD WIDTH=40></TD><TD ALIGN=LEFT VALIGN=TOP><B>ctx </B></TD><TD>- the context passed with eventhandler
</TD></TR></TABLE>
<P>
<P>
<H3><FONT COLOR="#CC3333">Keywords</FONT></H3>
<A HREF="../TS/TS.html#TS">TS</A>, event, set
<BR>
<P>
<H3><FONT COLOR="#CC3333">See Also</FONT></H3>
<A HREF="../TS/TSCreate.html#TSCreate">TSCreate</A>(), <A HREF="../TS/TSSetTimeStep.html#TSSetTimeStep">TSSetTimeStep</A>(), <A HREF="../TS/TSSetConvergedReason.html#TSSetConvergedReason">TSSetConvergedReason</A>()
<BR><P><B><P><B><FONT COLOR="#CC3333">Level:</FONT></B>intermediate
<BR><FONT COLOR="#CC3333">Location:</FONT></B><A HREF="../../../src/ts/event/tsevent.c.html#TSSetEventHandler">src/ts/event/tsevent.c</A>
<BR><A HREF="./index.html">Index of all TS routines</A>
<BR><A HREF="../../index.html">Table of Contents for all manual pages</A>
<BR><A HREF="../singleindex.html">Index of all manual pages</A>
<P><H3><FONT COLOR="#CC3333">Examples</FONT></H3>
<A HREF="../../../src/ts/examples/tutorials/ex40.c.html">src/ts/examples/tutorials/ex40.c.html</A><BR>
<A HREF="../../../src/ts/examples/tutorials/ex41.c.html">src/ts/examples/tutorials/ex41.c.html</A><BR>
</BODY></HTML>
|