xref: /petsc/include/petscts.h (revision c688c0463f6c25494d0d243b2a43b2b3454e025c)
1 /*
2    User interface for the timestepping package. This package
3    is for use in solving time-dependent PDEs.
4 */
5 #if !defined(__PETSCTS_H)
6 #define __PETSCTS_H
7 #include <petscsnes.h>
8 
9 /*S
10      TS - Abstract PETSc object that manages all time-steppers (ODE integrators)
11 
12    Level: beginner
13 
14   Concepts: ODE solvers
15 
16 .seealso:  TSCreate(), TSSetType(), TSType, SNES, KSP, PC
17 S*/
18 typedef struct _p_TS* TS;
19 
20 /*J
21     TSType - String with the name of a PETSc TS method or the creation function
22        with an optional dynamic library name, for example
23        http://www.mcs.anl.gov/petsc/lib.a:mytscreate()
24 
25    Level: beginner
26 
27 .seealso: TSSetType(), TS
28 J*/
29 typedef const char* TSType;
30 #define TSEULER           "euler"
31 #define TSBEULER          "beuler"
32 #define TSPSEUDO          "pseudo"
33 #define TSCN              "cn"
34 #define TSSUNDIALS        "sundials"
35 #define TSRK              "rk"
36 #define TSPYTHON          "python"
37 #define TSTHETA           "theta"
38 #define TSALPHA           "alpha"
39 #define TSGL              "gl"
40 #define TSSSP             "ssp"
41 #define TSARKIMEX         "arkimex"
42 #define TSROSW            "rosw"
43 
44 /*E
45     TSProblemType - Determines the type of problem this TS object is to be used to solve
46 
47    Level: beginner
48 
49 .seealso: TSCreate()
50 E*/
51 typedef enum {TS_LINEAR,TS_NONLINEAR} TSProblemType;
52 
53 /*E
54    TSConvergedReason - reason a TS method has converged or not
55 
56    Level: beginner
57 
58    Developer Notes: this must match finclude/petscts.h
59 
60    Each reason has its own manual page.
61 
62 .seealso: TSGetConvergedReason()
63 E*/
64 typedef enum {
65   TS_CONVERGED_ITERATING      = 0,
66   TS_CONVERGED_TIME           = 1,
67   TS_CONVERGED_ITS            = 2,
68   TS_DIVERGED_NONLINEAR_SOLVE = -1,
69   TS_DIVERGED_STEP_REJECTED   = -2
70 } TSConvergedReason;
71 PETSC_EXTERN const char *const*TSConvergedReasons;
72 
73 /*MC
74    TS_CONVERGED_ITERATING - this only occurs if TSGetConvergedReason() is called during the TSSolve()
75 
76    Level: beginner
77 
78 .seealso: TSSolve(), TSConvergedReason(), TSGetAdapt()
79 M*/
80 
81 /*MC
82    TS_CONVERGED_TIME - the final time was reached
83 
84    Level: beginner
85 
86 .seealso: TSSolve(), TSConvergedReason(), TSGetAdapt(), TSSetDuration()
87 M*/
88 
89 /*MC
90    TS_CONVERGED_ITS - the maximum number of iterations was reached prior to the final time
91 
92    Level: beginner
93 
94 .seealso: TSSolve(), TSConvergedReason(), TSGetAdapt(), TSSetDuration()
95 M*/
96 
97 /*MC
98    TS_DIVERGED_NONLINEAR_SOLVE - too many nonlinear solves failed
99 
100    Level: beginner
101 
102 .seealso: TSSolve(), TSConvergedReason(), TSGetAdapt(), TSGetSNES(), SNESGetConvergedReason()
103 M*/
104 
105 /*MC
106    TS_DIVERGED_STEP_REJECTED - too many steps were rejected
107 
108    Level: beginner
109 
110 .seealso: TSSolve(), TSConvergedReason(), TSGetAdapt()
111 M*/
112 
113 /* Logging support */
114 PETSC_EXTERN PetscClassId TS_CLASSID;
115 
116 PETSC_EXTERN PetscErrorCode TSInitializePackage(const char[]);
117 
118 PETSC_EXTERN PetscErrorCode TSCreate(MPI_Comm,TS*);
119 PETSC_EXTERN PetscErrorCode TSDestroy(TS*);
120 
121 PETSC_EXTERN PetscErrorCode TSSetProblemType(TS,TSProblemType);
122 PETSC_EXTERN PetscErrorCode TSGetProblemType(TS,TSProblemType*);
123 PETSC_EXTERN PetscErrorCode TSMonitor(TS,PetscInt,PetscReal,Vec);
124 PETSC_EXTERN PetscErrorCode TSMonitorSet(TS,PetscErrorCode(*)(TS,PetscInt,PetscReal,Vec,void*),void *,PetscErrorCode (*)(void**));
125 PETSC_EXTERN PetscErrorCode TSMonitorCancel(TS);
126 
127 PETSC_EXTERN PetscErrorCode TSSetOptionsPrefix(TS,const char[]);
128 PETSC_EXTERN PetscErrorCode TSAppendOptionsPrefix(TS,const char[]);
129 PETSC_EXTERN PetscErrorCode TSGetOptionsPrefix(TS,const char *[]);
130 PETSC_EXTERN PetscErrorCode TSSetFromOptions(TS);
131 PETSC_EXTERN PetscErrorCode TSSetUp(TS);
132 PETSC_EXTERN PetscErrorCode TSReset(TS);
133 
134 PETSC_EXTERN PetscErrorCode TSSetSolution(TS,Vec);
135 PETSC_EXTERN PetscErrorCode TSGetSolution(TS,Vec*);
136 
137 PETSC_EXTERN PetscErrorCode TSSetDuration(TS,PetscInt,PetscReal);
138 PETSC_EXTERN PetscErrorCode TSGetDuration(TS,PetscInt*,PetscReal*);
139 PETSC_EXTERN PetscErrorCode TSSetExactFinalTime(TS,PetscBool);
140 
141 PETSC_EXTERN PetscErrorCode TSMonitorDefault(TS,PetscInt,PetscReal,Vec,void*);
142 
143 typedef struct _n_TSMonitorDrawCtx*  TSMonitorDrawCtx;
144 PETSC_EXTERN PetscErrorCode TSMonitorDrawCtxCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscInt,TSMonitorDrawCtx *);
145 PETSC_EXTERN PetscErrorCode TSMonitorDrawCtxDestroy(TSMonitorDrawCtx*);
146 PETSC_EXTERN PetscErrorCode TSMonitorDrawSolution(TS,PetscInt,PetscReal,Vec,void*);
147 PETSC_EXTERN PetscErrorCode TSMonitorDrawError(TS,PetscInt,PetscReal,Vec,void*);
148 
149 PETSC_EXTERN PetscErrorCode TSMonitorSolutionBinary(TS,PetscInt,PetscReal,Vec,void*);
150 PETSC_EXTERN PetscErrorCode TSMonitorSolutionVTK(TS,PetscInt,PetscReal,Vec,void*);
151 PETSC_EXTERN PetscErrorCode TSMonitorSolutionVTKDestroy(void*);
152 
153 PETSC_EXTERN PetscErrorCode TSStep(TS);
154 PETSC_EXTERN PetscErrorCode TSEvaluateStep(TS,PetscInt,Vec,PetscBool*);
155 PETSC_EXTERN PetscErrorCode TSSolve(TS,Vec,PetscReal*);
156 PETSC_EXTERN PetscErrorCode TSGetConvergedReason(TS,TSConvergedReason*);
157 PETSC_EXTERN PetscErrorCode TSGetSNESIterations(TS,PetscInt*);
158 PETSC_EXTERN PetscErrorCode TSGetKSPIterations(TS,PetscInt*);
159 PETSC_EXTERN PetscErrorCode TSGetStepRejections(TS,PetscInt*);
160 PETSC_EXTERN PetscErrorCode TSSetMaxStepRejections(TS,PetscInt);
161 PETSC_EXTERN PetscErrorCode TSGetSNESFailures(TS,PetscInt*);
162 PETSC_EXTERN PetscErrorCode TSSetMaxSNESFailures(TS,PetscInt);
163 PETSC_EXTERN PetscErrorCode TSSetErrorIfStepFails(TS,PetscBool);
164 
165 PETSC_EXTERN PetscErrorCode TSSetInitialTimeStep(TS,PetscReal,PetscReal);
166 PETSC_EXTERN PetscErrorCode TSGetTimeStep(TS,PetscReal*);
167 PETSC_EXTERN PetscErrorCode TSGetTime(TS,PetscReal*);
168 PETSC_EXTERN PetscErrorCode TSSetTime(TS,PetscReal);
169 PETSC_EXTERN PetscErrorCode TSGetTimeStepNumber(TS,PetscInt*);
170 PETSC_EXTERN PetscErrorCode TSSetTimeStep(TS,PetscReal);
171 
172 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSRHSFunction)(TS,PetscReal,Vec,Vec,void*);
173 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSRHSJacobian)(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);
174 PETSC_EXTERN PetscErrorCode TSSetRHSFunction(TS,Vec,TSRHSFunction,void*);
175 PETSC_EXTERN PetscErrorCode TSGetRHSFunction(TS,Vec*,TSRHSFunction*,void**);
176 PETSC_EXTERN PetscErrorCode TSSetRHSJacobian(TS,Mat,Mat,TSRHSJacobian,void*);
177 PETSC_EXTERN PetscErrorCode TSGetRHSJacobian(TS,Mat*,Mat*,TSRHSJacobian*,void**);
178 
179 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSSolutionFunction)(TS,PetscReal,Vec,void*);
180 PETSC_EXTERN PetscErrorCode TSSetSolutionFunction(TS,TSSolutionFunction,void*);
181 
182 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSIFunction)(TS,PetscReal,Vec,Vec,Vec,void*);
183 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSIJacobian)(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
184 PETSC_EXTERN PetscErrorCode TSSetIFunction(TS,Vec,TSIFunction,void*);
185 PETSC_EXTERN PetscErrorCode TSGetIFunction(TS,Vec*,TSIFunction*,void**);
186 PETSC_EXTERN PetscErrorCode TSSetIJacobian(TS,Mat,Mat,TSIJacobian,void*);
187 PETSC_EXTERN PetscErrorCode TSGetIJacobian(TS,Mat*,Mat*,TSIJacobian*,void**);
188 
189 PETSC_EXTERN PetscErrorCode TSComputeRHSFunctionLinear(TS,PetscReal,Vec,Vec,void*);
190 PETSC_EXTERN PetscErrorCode TSComputeRHSJacobianConstant(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);
191 PETSC_EXTERN PetscErrorCode TSComputeIFunctionLinear(TS,PetscReal,Vec,Vec,Vec,void*);
192 PETSC_EXTERN PetscErrorCode TSComputeIJacobianConstant(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,void*);
193 PETSC_EXTERN PetscErrorCode TSComputeSolutionFunction(TS,PetscReal,Vec);
194 
195 PETSC_EXTERN PetscErrorCode TSSetPreStep(TS, PetscErrorCode (*)(TS));
196 PETSC_EXTERN PetscErrorCode TSSetPreStage(TS, PetscErrorCode (*)(TS,PetscReal));
197 PETSC_EXTERN PetscErrorCode TSSetPostStep(TS, PetscErrorCode (*)(TS));
198 PETSC_EXTERN PetscErrorCode TSPreStep(TS);
199 PETSC_EXTERN PetscErrorCode TSPreStage(TS,PetscReal);
200 PETSC_EXTERN PetscErrorCode TSPostStep(TS);
201 PETSC_EXTERN PetscErrorCode TSSetRetainStages(TS,PetscBool);
202 PETSC_EXTERN PetscErrorCode TSInterpolate(TS,PetscReal,Vec);
203 PETSC_EXTERN PetscErrorCode TSSetTolerances(TS,PetscReal,Vec,PetscReal,Vec);
204 PETSC_EXTERN PetscErrorCode TSGetTolerances(TS,PetscReal*,Vec*,PetscReal*,Vec*);
205 PETSC_EXTERN PetscErrorCode TSErrorNormWRMS(TS,Vec,PetscReal*);
206 PETSC_EXTERN PetscErrorCode TSSetCFLTimeLocal(TS,PetscReal);
207 PETSC_EXTERN PetscErrorCode TSGetCFLTime(TS,PetscReal*);
208 
209 PETSC_EXTERN PetscErrorCode TSPseudoSetTimeStep(TS,PetscErrorCode(*)(TS,PetscReal*,void*),void*);
210 PETSC_EXTERN PetscErrorCode TSPseudoDefaultTimeStep(TS,PetscReal*,void*);
211 PETSC_EXTERN PetscErrorCode TSPseudoComputeTimeStep(TS,PetscReal *);
212 PETSC_EXTERN PetscErrorCode TSPseudoSetMaxTimeStep(TS,PetscReal);
213 
214 PETSC_EXTERN PetscErrorCode TSPseudoSetVerifyTimeStep(TS,PetscErrorCode(*)(TS,Vec,void*,PetscReal*,PetscBool *),void*);
215 PETSC_EXTERN PetscErrorCode TSPseudoDefaultVerifyTimeStep(TS,Vec,void*,PetscReal*,PetscBool *);
216 PETSC_EXTERN PetscErrorCode TSPseudoVerifyTimeStep(TS,Vec,PetscReal*,PetscBool *);
217 PETSC_EXTERN PetscErrorCode TSPseudoSetTimeStepIncrement(TS,PetscReal);
218 PETSC_EXTERN PetscErrorCode TSPseudoIncrementDtFromInitialDt(TS);
219 
220 PETSC_EXTERN PetscErrorCode TSPythonSetType(TS,const char[]);
221 
222 PETSC_EXTERN PetscErrorCode TSComputeRHSFunction(TS,PetscReal,Vec,Vec);
223 PETSC_EXTERN PetscErrorCode TSComputeRHSJacobian(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*);
224 PETSC_EXTERN PetscErrorCode TSComputeIFunction(TS,PetscReal,Vec,Vec,Vec,PetscBool);
225 PETSC_EXTERN PetscErrorCode TSComputeIJacobian(TS,PetscReal,Vec,Vec,PetscReal,Mat*,Mat*,MatStructure*,PetscBool);
226 PETSC_EXTERN PetscErrorCode TSComputeLinearStability(TS,PetscReal,PetscReal,PetscReal*,PetscReal*);
227 
228 PETSC_EXTERN PetscErrorCode TSVISetVariableBounds(TS,Vec,Vec);
229 
230 PETSC_EXTERN PetscErrorCode DMTSSetRHSFunction(DM,TSRHSFunction,void*);
231 PETSC_EXTERN PetscErrorCode DMTSGetRHSFunction(DM,TSRHSFunction*,void**);
232 PETSC_EXTERN PetscErrorCode DMTSSetRHSJacobian(DM,TSRHSJacobian,void*);
233 PETSC_EXTERN PetscErrorCode DMTSGetRHSJacobian(DM,TSRHSJacobian*,void**);
234 PETSC_EXTERN PetscErrorCode DMTSSetIFunction(DM,TSIFunction,void*);
235 PETSC_EXTERN PetscErrorCode DMTSGetIFunction(DM,TSIFunction*,void**);
236 PETSC_EXTERN PetscErrorCode DMTSSetIJacobian(DM,TSIJacobian,void*);
237 PETSC_EXTERN PetscErrorCode DMTSGetIJacobian(DM,TSIJacobian*,void**);
238 PETSC_EXTERN PetscErrorCode DMTSSetSolutionFunction(DM,TSSolutionFunction,void*);
239 PETSC_EXTERN PetscErrorCode DMTSGetSolutionFunction(DM,TSSolutionFunction*,void**);
240 
241 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSRHSFunctionLocal)(DMDALocalInfo*,PetscReal,void*,void*,void*);
242 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSRHSJacobianLocal)(DMDALocalInfo*,PetscReal,void*,Mat,Mat,MatStructure*,void*);
243 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSIFunctionLocal)(DMDALocalInfo*,PetscReal,void*,void*,void*,void*);
244 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*DMDATSIJacobianLocal)(DMDALocalInfo*,PetscReal,void*,void*,PetscReal,Mat,Mat,MatStructure*,void*);
245 
246 PETSC_EXTERN PetscErrorCode DMDATSSetRHSFunctionLocal(DM,InsertMode,PetscErrorCode (*)(DMDALocalInfo*,PetscReal,void*,void*,void*),void *);
247 PETSC_EXTERN PetscErrorCode DMDATSSetRHSJacobianLocal(DM,PetscErrorCode (*)(DMDALocalInfo*,PetscReal,void*,Mat,Mat,MatStructure*,void*),void *);
248 PETSC_EXTERN PetscErrorCode DMDATSSetIFunctionLocal(DM,InsertMode,PetscErrorCode (*)(DMDALocalInfo*,PetscReal,void*,void*,void*,void*),void *);
249 PETSC_EXTERN PetscErrorCode DMDATSSetIJacobianLocal(DM,PetscErrorCode (*)(DMDALocalInfo*,PetscReal,void*,void*,PetscReal,Mat,Mat,MatStructure*,void*),void *);
250 
251 /* Dynamic creation and loading functions */
252 PETSC_EXTERN PetscFList TSList;
253 PETSC_EXTERN PetscBool TSRegisterAllCalled;
254 PETSC_EXTERN PetscErrorCode TSGetType(TS,TSType*);
255 PETSC_EXTERN PetscErrorCode TSSetType(TS,TSType);
256 PETSC_EXTERN PetscErrorCode TSRegister(const char[], const char[], const char[], PetscErrorCode (*)(TS));
257 PETSC_EXTERN PetscErrorCode TSRegisterAll(const char[]);
258 PETSC_EXTERN PetscErrorCode TSRegisterDestroy(void);
259 
260 /*MC
261   TSRegisterDynamic - Adds a creation method to the TS package.
262 
263   Synopsis:
264   PetscErrorCode TSRegisterDynamic(const char *name, const char *path, const char *func_name, PetscErrorCode (*create_func)(TS))
265 
266   Not Collective
267 
268   Input Parameters:
269 + name        - The name of a new user-defined creation routine
270 . path        - The path (either absolute or relative) of the library containing this routine
271 . func_name   - The name of the creation routine
272 - create_func - The creation routine itself
273 
274   Notes:
275   TSRegisterDynamic() may be called multiple times to add several user-defined tses.
276 
277   If dynamic libraries are used, then the fourth input argument (create_func) is ignored.
278 
279   Sample usage:
280 .vb
281   TSRegisterDynamic("my_ts", "/home/username/my_lib/lib/libO/solaris/libmy.a", "MyTSCreate", MyTSCreate);
282 .ve
283 
284   Then, your ts type can be chosen with the procedural interface via
285 .vb
286     TS ts;
287     TSCreate(MPI_Comm, &ts);
288     TSSetType(ts, "my_ts")
289 .ve
290   or at runtime via the option
291 .vb
292     -ts_type my_ts
293 .ve
294 
295   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
296         If your function is not being put into a shared library then use TSRegister() instead
297 
298   Level: advanced
299 
300 .keywords: TS, register
301 .seealso: TSRegisterAll(), TSRegisterDestroy()
302 M*/
303 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
304 #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,0)
305 #else
306 #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,d)
307 #endif
308 
309 PETSC_EXTERN PetscErrorCode TSGetSNES(TS,SNES*);
310 PETSC_EXTERN PetscErrorCode TSGetKSP(TS,KSP*);
311 
312 PETSC_EXTERN PetscErrorCode TSView(TS,PetscViewer);
313 
314 PETSC_EXTERN PetscErrorCode TSSetApplicationContext(TS,void *);
315 PETSC_EXTERN PetscErrorCode TSGetApplicationContext(TS,void *);
316 
317 typedef struct _n_TSMonitorLGCtx*  TSMonitorLGCtx;
318 PETSC_EXTERN PetscErrorCode TSMonitorLGCtxCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscInt,TSMonitorLGCtx *);
319 PETSC_EXTERN PetscErrorCode TSMonitorLGCtxDestroy(TSMonitorLGCtx*);
320 PETSC_EXTERN PetscErrorCode TSMonitorLGTimeStep(TS,PetscInt,PetscReal,Vec,void *);
321 PETSC_EXTERN PetscErrorCode TSMonitorLGSolution(TS,PetscInt,PetscReal,Vec,void *);
322 PETSC_EXTERN PetscErrorCode TSMonitorLGError(TS,PetscInt,PetscReal,Vec,void *);
323 PETSC_EXTERN PetscErrorCode TSMonitorLGSNESIterations(TS,PetscInt,PetscReal,Vec,void *);
324 PETSC_EXTERN PetscErrorCode TSMonitorLGKSPIterations(TS,PetscInt,PetscReal,Vec,void *);
325 
326 typedef struct _n_TSMonitorSPEigCtx*  TSMonitorSPEigCtx;
327 PETSC_EXTERN PetscErrorCode TSMonitorSPEigCtxCreate(MPI_Comm,const char[],const char[],int,int,int,int,PetscInt,TSMonitorSPEigCtx *);
328 PETSC_EXTERN PetscErrorCode TSMonitorSPEigCtxDestroy(TSMonitorSPEigCtx*);
329 PETSC_EXTERN PetscErrorCode TSMonitorSPEig(TS,PetscInt,PetscReal,Vec,void *);
330 
331 /*J
332    TSSSPType - string with the name of TSSSP scheme.
333 
334    Level: beginner
335 
336 .seealso: TSSSPSetType(), TS
337 J*/
338 typedef const char* TSSSPType;
339 #define TSSSPRKS2  "rks2"
340 #define TSSSPRKS3  "rks3"
341 #define TSSSPRK104 "rk104"
342 
343 PETSC_EXTERN PetscErrorCode TSSSPSetType(TS,TSSSPType);
344 PETSC_EXTERN PetscErrorCode TSSSPGetType(TS,TSSSPType*);
345 PETSC_EXTERN PetscErrorCode TSSSPSetNumStages(TS,PetscInt);
346 PETSC_EXTERN PetscErrorCode TSSSPGetNumStages(TS,PetscInt*);
347 
348 /*S
349    TSAdapt - Abstract object that manages time-step adaptivity
350 
351    Level: beginner
352 
353 .seealso: TS, TSAdaptCreate(), TSAdaptType
354 S*/
355 typedef struct _p_TSAdapt *TSAdapt;
356 
357 /*E
358     TSAdaptType - String with the name of TSAdapt scheme or the creation function
359        with an optional dynamic library name, for example
360        http://www.mcs.anl.gov/petsc/lib.a:mytsgladaptcreate()
361 
362    Level: beginner
363 
364 .seealso: TSAdaptSetType(), TS
365 E*/
366 typedef const char *TSAdaptType;
367 #define TSADAPTBASIC "basic"
368 #define TSADAPTNONE  "none"
369 #define TSADAPTCFL   "cfl"
370 
371 /*MC
372    TSAdaptRegisterDynamic - adds a TSAdapt implementation
373 
374    Synopsis:
375    PetscErrorCode TSAdaptRegisterDynamic(const char *name_scheme,const char *path,const char *name_create,PetscErrorCode (*routine_create)(TS))
376 
377    Not Collective
378 
379    Input Parameters:
380 +  name_scheme - name of user-defined adaptivity scheme
381 .  path - path (either absolute or relative) the library containing this scheme
382 .  name_create - name of routine to create method context
383 -  routine_create - routine to create method context
384 
385    Notes:
386    TSAdaptRegisterDynamic() may be called multiple times to add several user-defined families.
387 
388    If dynamic libraries are used, then the fourth input argument (routine_create)
389    is ignored.
390 
391    Sample usage:
392 .vb
393    TSAdaptRegisterDynamic("my_scheme",/home/username/my_lib/lib/libO/solaris/mylib.a,
394                             "MySchemeCreate",MySchemeCreate);
395 .ve
396 
397    Then, your scheme can be chosen with the procedural interface via
398 $     TSAdaptSetType(ts,"my_scheme")
399    or at runtime via the option
400 $     -ts_adapt_type my_scheme
401 
402    Level: advanced
403 
404    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
405           and others of the form ${any_environmental_variable} occuring in pathname will be
406           replaced with appropriate values.
407 
408 .keywords: TSAdapt, register
409 
410 .seealso: TSAdaptRegisterAll()
411 M*/
412 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
413 #  define TSAdaptRegisterDynamic(a,b,c,d)  TSAdaptRegister(a,b,c,0)
414 #else
415 #  define TSAdaptRegisterDynamic(a,b,c,d)  TSAdaptRegister(a,b,c,d)
416 #endif
417 
418 PETSC_EXTERN PetscErrorCode TSGetAdapt(TS,TSAdapt*);
419 PETSC_EXTERN PetscErrorCode TSAdaptRegister(const char[],const char[],const char[],PetscErrorCode (*)(TSAdapt));
420 PETSC_EXTERN PetscErrorCode TSAdaptRegisterAll(const char[]);
421 PETSC_EXTERN PetscErrorCode TSAdaptRegisterDestroy(void);
422 PETSC_EXTERN PetscErrorCode TSAdaptInitializePackage(const char[]);
423 PETSC_EXTERN PetscErrorCode TSAdaptFinalizePackage(void);
424 PETSC_EXTERN PetscErrorCode TSAdaptCreate(MPI_Comm,TSAdapt*);
425 PETSC_EXTERN PetscErrorCode TSAdaptSetType(TSAdapt,TSAdaptType);
426 PETSC_EXTERN PetscErrorCode TSAdaptSetOptionsPrefix(TSAdapt,const char[]);
427 PETSC_EXTERN PetscErrorCode TSAdaptCandidatesClear(TSAdapt);
428 PETSC_EXTERN PetscErrorCode TSAdaptCandidateAdd(TSAdapt,const char[],PetscInt,PetscInt,PetscReal,PetscReal,PetscBool);
429 PETSC_EXTERN PetscErrorCode TSAdaptCandidatesGet(TSAdapt,PetscInt*,const PetscInt**,const PetscInt**,const PetscReal**,const PetscReal**);
430 PETSC_EXTERN PetscErrorCode TSAdaptChoose(TSAdapt,TS,PetscReal,PetscInt*,PetscReal*,PetscBool*);
431 PETSC_EXTERN PetscErrorCode TSAdaptCheckStage(TSAdapt,TS,PetscBool*);
432 PETSC_EXTERN PetscErrorCode TSAdaptView(TSAdapt,PetscViewer);
433 PETSC_EXTERN PetscErrorCode TSAdaptSetFromOptions(TSAdapt);
434 PETSC_EXTERN PetscErrorCode TSAdaptDestroy(TSAdapt*);
435 PETSC_EXTERN PetscErrorCode TSAdaptSetMonitor(TSAdapt,PetscBool);
436 PETSC_EXTERN PetscErrorCode TSAdaptSetStepLimits(TSAdapt,PetscReal,PetscReal);
437 PETSC_EXTERN PetscErrorCode TSAdaptSetCheckStage(TSAdapt,PetscErrorCode(*)(TSAdapt,TS,PetscBool*));
438 
439 /*S
440    TSGLAdapt - Abstract object that manages time-step adaptivity
441 
442    Level: beginner
443 
444    Developer Notes:
445    This functionality should be replaced by the TSAdapt.
446 
447 .seealso: TSGL, TSGLAdaptCreate(), TSGLAdaptType
448 S*/
449 typedef struct _p_TSGLAdapt *TSGLAdapt;
450 
451 /*J
452     TSGLAdaptType - String with the name of TSGLAdapt scheme or the creation function
453        with an optional dynamic library name, for example
454        http://www.mcs.anl.gov/petsc/lib.a:mytsgladaptcreate()
455 
456    Level: beginner
457 
458 .seealso: TSGLAdaptSetType(), TS
459 J*/
460 typedef const char *TSGLAdaptType;
461 #define TSGLADAPT_NONE "none"
462 #define TSGLADAPT_SIZE "size"
463 #define TSGLADAPT_BOTH "both"
464 
465 /*MC
466    TSGLAdaptRegisterDynamic - adds a TSGLAdapt implementation
467 
468    Synopsis:
469    PetscErrorCode TSGLAdaptRegisterDynamic(const char *name_scheme,const char *path,const char *name_create,PetscErrorCode (*routine_create)(TS))
470 
471    Not Collective
472 
473    Input Parameters:
474 +  name_scheme - name of user-defined adaptivity scheme
475 .  path - path (either absolute or relative) the library containing this scheme
476 .  name_create - name of routine to create method context
477 -  routine_create - routine to create method context
478 
479    Notes:
480    TSGLAdaptRegisterDynamic() may be called multiple times to add several user-defined families.
481 
482    If dynamic libraries are used, then the fourth input argument (routine_create)
483    is ignored.
484 
485    Sample usage:
486 .vb
487    TSGLAdaptRegisterDynamic("my_scheme",/home/username/my_lib/lib/libO/solaris/mylib.a,
488                             "MySchemeCreate",MySchemeCreate);
489 .ve
490 
491    Then, your scheme can be chosen with the procedural interface via
492 $     TSGLAdaptSetType(ts,"my_scheme")
493    or at runtime via the option
494 $     -ts_adapt_type my_scheme
495 
496    Level: advanced
497 
498    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
499           and others of the form ${any_environmental_variable} occuring in pathname will be
500           replaced with appropriate values.
501 
502 .keywords: TSGLAdapt, register
503 
504 .seealso: TSGLAdaptRegisterAll()
505 M*/
506 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
507 #  define TSGLAdaptRegisterDynamic(a,b,c,d)  TSGLAdaptRegister(a,b,c,0)
508 #else
509 #  define TSGLAdaptRegisterDynamic(a,b,c,d)  TSGLAdaptRegister(a,b,c,d)
510 #endif
511 
512 PETSC_EXTERN PetscErrorCode TSGLAdaptRegister(const char[],const char[],const char[],PetscErrorCode (*)(TSGLAdapt));
513 PETSC_EXTERN PetscErrorCode TSGLAdaptRegisterAll(const char[]);
514 PETSC_EXTERN PetscErrorCode TSGLAdaptRegisterDestroy(void);
515 PETSC_EXTERN PetscErrorCode TSGLAdaptInitializePackage(const char[]);
516 PETSC_EXTERN PetscErrorCode TSGLAdaptFinalizePackage(void);
517 PETSC_EXTERN PetscErrorCode TSGLAdaptCreate(MPI_Comm,TSGLAdapt*);
518 PETSC_EXTERN PetscErrorCode TSGLAdaptSetType(TSGLAdapt,TSGLAdaptType);
519 PETSC_EXTERN PetscErrorCode TSGLAdaptSetOptionsPrefix(TSGLAdapt,const char[]);
520 PETSC_EXTERN PetscErrorCode TSGLAdaptChoose(TSGLAdapt,PetscInt,const PetscInt[],const PetscReal[],const PetscReal[],PetscInt,PetscReal,PetscReal,PetscInt*,PetscReal*,PetscBool *);
521 PETSC_EXTERN PetscErrorCode TSGLAdaptView(TSGLAdapt,PetscViewer);
522 PETSC_EXTERN PetscErrorCode TSGLAdaptSetFromOptions(TSGLAdapt);
523 PETSC_EXTERN PetscErrorCode TSGLAdaptDestroy(TSGLAdapt*);
524 
525 /*J
526     TSGLAcceptType - String with the name of TSGLAccept scheme or the function
527        with an optional dynamic library name, for example
528        http://www.mcs.anl.gov/petsc/lib.a:mytsglaccept()
529 
530    Level: beginner
531 
532 .seealso: TSGLSetAcceptType(), TS
533 J*/
534 typedef const char *TSGLAcceptType;
535 #define TSGLACCEPT_ALWAYS "always"
536 
537 PETSC_EXTERN_TYPEDEF typedef PetscErrorCode (*TSGLAcceptFunction)(TS,PetscReal,PetscReal,const PetscReal[],PetscBool *);
538 PETSC_EXTERN PetscErrorCode TSGLAcceptRegister(const char[],const char[],const char[],TSGLAcceptFunction);
539 
540 /*MC
541    TSGLAcceptRegisterDynamic - adds a TSGL acceptance scheme
542 
543    Synopsis:
544    PetscErrorCode TSGLAcceptRegisterDynamic(const char *name_scheme,const char *path,const char *name_create,PetscErrorCode (*routine_create)(TS))
545 
546    Not Collective
547 
548    Input Parameters:
549 +  name_scheme - name of user-defined acceptance scheme
550 .  path - path (either absolute or relative) the library containing this scheme
551 .  name_create - name of routine to create method context
552 -  routine_create - routine to create method context
553 
554    Notes:
555    TSGLAcceptRegisterDynamic() may be called multiple times to add several user-defined families.
556 
557    If dynamic libraries are used, then the fourth input argument (routine_create)
558    is ignored.
559 
560    Sample usage:
561 .vb
562    TSGLAcceptRegisterDynamic("my_scheme",/home/username/my_lib/lib/libO/solaris/mylib.a,
563                              "MySchemeCreate",MySchemeCreate);
564 .ve
565 
566    Then, your scheme can be chosen with the procedural interface via
567 $     TSGLSetAcceptType(ts,"my_scheme")
568    or at runtime via the option
569 $     -ts_gl_accept_type my_scheme
570 
571    Level: advanced
572 
573    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
574           and others of the form ${any_environmental_variable} occuring in pathname will be
575           replaced with appropriate values.
576 
577 .keywords: TSGL, TSGLAcceptType, register
578 
579 .seealso: TSGLRegisterAll()
580 M*/
581 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
582 #  define TSGLAcceptRegisterDynamic(a,b,c,d) TSGLAcceptRegister(a,b,c,0)
583 #else
584 #  define TSGLAcceptRegisterDynamic(a,b,c,d) TSGLAcceptRegister(a,b,c,d)
585 #endif
586 
587 /*J
588   TSGLType - family of time integration method within the General Linear class
589 
590   Level: beginner
591 
592 .seealso: TSGLSetType(), TSGLRegister()
593 J*/
594 typedef const char* TSGLType;
595 #define TSGL_IRKS   "irks"
596 
597 /*MC
598    TSGLRegisterDynamic - adds a TSGL implementation
599 
600    Synopsis:
601    PetscErrorCode TSGLRegisterDynamic(const char *name_scheme,const char *path,const char *name_create,PetscErrorCode (*routine_create)(TS))
602 
603    Not Collective
604 
605    Input Parameters:
606 +  name_scheme - name of user-defined general linear scheme
607 .  path - path (either absolute or relative) the library containing this scheme
608 .  name_create - name of routine to create method context
609 -  routine_create - routine to create method context
610 
611    Notes:
612    TSGLRegisterDynamic() may be called multiple times to add several user-defined families.
613 
614    If dynamic libraries are used, then the fourth input argument (routine_create)
615    is ignored.
616 
617    Sample usage:
618 .vb
619    TSGLRegisterDynamic("my_scheme",/home/username/my_lib/lib/libO/solaris/mylib.a,
620                        "MySchemeCreate",MySchemeCreate);
621 .ve
622 
623    Then, your scheme can be chosen with the procedural interface via
624 $     TSGLSetType(ts,"my_scheme")
625    or at runtime via the option
626 $     -ts_gl_type my_scheme
627 
628    Level: advanced
629 
630    Notes: Environmental variables such as ${PETSC_ARCH}, ${PETSC_DIR}, ${PETSC_LIB_DIR},
631           and others of the form ${any_environmental_variable} occuring in pathname will be
632           replaced with appropriate values.
633 
634 .keywords: TSGL, register
635 
636 .seealso: TSGLRegisterAll()
637 M*/
638 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
639 #  define TSGLRegisterDynamic(a,b,c,d)       TSGLRegister(a,b,c,0)
640 #else
641 #  define TSGLRegisterDynamic(a,b,c,d)       TSGLRegister(a,b,c,d)
642 #endif
643 
644 PETSC_EXTERN PetscErrorCode TSGLRegister(const char[],const char[],const char[],PetscErrorCode(*)(TS));
645 PETSC_EXTERN PetscErrorCode TSGLRegisterAll(const char[]);
646 PETSC_EXTERN PetscErrorCode TSGLRegisterDestroy(void);
647 PETSC_EXTERN PetscErrorCode TSGLInitializePackage(const char[]);
648 PETSC_EXTERN PetscErrorCode TSGLFinalizePackage(void);
649 PETSC_EXTERN PetscErrorCode TSGLSetType(TS,TSGLType);
650 PETSC_EXTERN PetscErrorCode TSGLGetAdapt(TS,TSGLAdapt*);
651 PETSC_EXTERN PetscErrorCode TSGLSetAcceptType(TS,TSGLAcceptType);
652 
653 /*J
654     TSARKIMEXType - String with the name of an Additive Runge-Kutta IMEX method.
655 
656    Level: beginner
657 
658 .seealso: TSARKIMEXSetType(), TS, TSARKIMEX, TSARKIMEXRegister()
659 J*/
660 typedef const char* TSARKIMEXType;
661 #define TSARKIMEXA2     "a2"
662 #define TSARKIMEXL2     "l2"
663 #define TSARKIMEXARS122 "ars122"
664 #define TSARKIMEX2C     "2c"
665 #define TSARKIMEX2D     "2d"
666 #define TSARKIMEX2E     "2e"
667 #define TSARKIMEXPRSSP2 "prssp2"
668 #define TSARKIMEX3      "3"
669 #define TSARKIMEXBPR3   "bpr3"
670 #define TSARKIMEXARS443 "ars443"
671 #define TSARKIMEX4      "4"
672 #define TSARKIMEX5      "5"
673 PETSC_EXTERN PetscErrorCode TSARKIMEXGetType(TS ts,TSARKIMEXType*);
674 PETSC_EXTERN PetscErrorCode TSARKIMEXSetType(TS ts,TSARKIMEXType);
675 PETSC_EXTERN PetscErrorCode TSARKIMEXSetFullyImplicit(TS,PetscBool);
676 PETSC_EXTERN PetscErrorCode TSARKIMEXRegister(TSARKIMEXType,PetscInt,PetscInt,const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],PetscInt,const PetscReal[],const PetscReal[]);
677 PETSC_EXTERN PetscErrorCode TSARKIMEXFinalizePackage(void);
678 PETSC_EXTERN PetscErrorCode TSARKIMEXInitializePackage(const char path[]);
679 PETSC_EXTERN PetscErrorCode TSARKIMEXRegisterDestroy(void);
680 PETSC_EXTERN PetscErrorCode TSARKIMEXRegisterAll(void);
681 
682 /*J
683     TSRosWType - String with the name of a Rosenbrock-W method.
684 
685    Level: beginner
686 
687 .seealso: TSRosWSetType(), TS, TSROSW, TSRosWRegister()
688 J*/
689 typedef const char* TSRosWType;
690 #define TSROSW2M          "2m"
691 #define TSROSW2P          "2p"
692 #define TSROSWRA3PW       "ra3pw"
693 #define TSROSWRA34PW2     "ra34pw2"
694 #define TSROSWRODAS3      "rodas3"
695 #define TSROSWSANDU3      "sandu3"
696 #define TSROSWASSP3P3S1C  "assp3p3s1c"
697 #define TSROSWLASSP3P4S2C "lassp3p4s2c"
698 #define TSROSWLLSSP3P4S2C "llssp3p4s2c"
699 #define TSROSWARK3        "ark3"
700 #define TSROSWTHETA1      "theta1"
701 #define TSROSWTHETA2      "theta2"
702 #define TSROSWGRK4T       "grk4t"
703 #define TSROSWSHAMP4      "shamp4"
704 #define TSROSWVELDD4      "veldd4"
705 #define TSROSW4L          "4l"
706 
707 PETSC_EXTERN PetscErrorCode TSRosWGetType(TS ts,TSRosWType*);
708 PETSC_EXTERN PetscErrorCode TSRosWSetType(TS ts,TSRosWType);
709 PETSC_EXTERN PetscErrorCode TSRosWSetRecomputeJacobian(TS,PetscBool);
710 PETSC_EXTERN PetscErrorCode TSRosWRegister(TSRosWType,PetscInt,PetscInt,const PetscReal[],const PetscReal[],const PetscReal[],const PetscReal[],PetscInt,const PetscReal[]);
711 PETSC_EXTERN PetscErrorCode TSRosWRegisterRos4(TSRosWType,PetscReal,PetscReal,PetscReal,PetscReal,PetscReal);
712 PETSC_EXTERN PetscErrorCode TSRosWFinalizePackage(void);
713 PETSC_EXTERN PetscErrorCode TSRosWInitializePackage(const char path[]);
714 PETSC_EXTERN PetscErrorCode TSRosWRegisterDestroy(void);
715 PETSC_EXTERN PetscErrorCode TSRosWRegisterAll(void);
716 
717 /*
718        PETSc interface to Sundials
719 */
720 #ifdef PETSC_HAVE_SUNDIALS
721 typedef enum { SUNDIALS_ADAMS=1,SUNDIALS_BDF=2} TSSundialsLmmType;
722 PETSC_EXTERN const char *const TSSundialsLmmTypes[];
723 typedef enum { SUNDIALS_MODIFIED_GS = 1,SUNDIALS_CLASSICAL_GS = 2 } TSSundialsGramSchmidtType;
724 PETSC_EXTERN const char *const TSSundialsGramSchmidtTypes[];
725 PETSC_EXTERN PetscErrorCode TSSundialsSetType(TS,TSSundialsLmmType);
726 PETSC_EXTERN PetscErrorCode TSSundialsGetPC(TS,PC*);
727 PETSC_EXTERN PetscErrorCode TSSundialsSetTolerance(TS,PetscReal,PetscReal);
728 PETSC_EXTERN PetscErrorCode TSSundialsSetMinTimeStep(TS,PetscReal);
729 PETSC_EXTERN PetscErrorCode TSSundialsSetMaxTimeStep(TS,PetscReal);
730 PETSC_EXTERN PetscErrorCode TSSundialsGetIterations(TS,PetscInt *,PetscInt *);
731 PETSC_EXTERN PetscErrorCode TSSundialsSetGramSchmidtType(TS,TSSundialsGramSchmidtType);
732 PETSC_EXTERN PetscErrorCode TSSundialsSetGMRESRestart(TS,PetscInt);
733 PETSC_EXTERN PetscErrorCode TSSundialsSetLinearTolerance(TS,PetscReal);
734 PETSC_EXTERN PetscErrorCode TSSundialsMonitorInternalSteps(TS,PetscBool );
735 PETSC_EXTERN PetscErrorCode TSSundialsGetParameters(TS,PetscInt *,long*[],double*[]);
736 PETSC_EXTERN PetscErrorCode TSSundialsSetMaxl(TS,PetscInt);
737 #endif
738 
739 PETSC_EXTERN PetscErrorCode TSRKSetTolerance(TS,PetscReal);
740 
741 PETSC_EXTERN PetscErrorCode TSThetaSetTheta(TS,PetscReal);
742 PETSC_EXTERN PetscErrorCode TSThetaGetTheta(TS,PetscReal*);
743 PETSC_EXTERN PetscErrorCode TSThetaGetEndpoint(TS,PetscBool*);
744 PETSC_EXTERN PetscErrorCode TSThetaSetEndpoint(TS,PetscBool);
745 
746 PETSC_EXTERN PetscErrorCode TSAlphaSetAdapt(TS,PetscErrorCode(*)(TS,PetscReal,Vec,Vec,PetscReal*,PetscBool*,void*),void*);
747 PETSC_EXTERN PetscErrorCode TSAlphaAdaptDefault(TS,PetscReal,Vec,Vec,PetscReal*,PetscBool*,void*);
748 PETSC_EXTERN PetscErrorCode TSAlphaSetRadius(TS,PetscReal);
749 PETSC_EXTERN PetscErrorCode TSAlphaSetParams(TS,PetscReal,PetscReal,PetscReal);
750 PETSC_EXTERN PetscErrorCode TSAlphaGetParams(TS,PetscReal*,PetscReal*,PetscReal*);
751 
752 PETSC_EXTERN PetscErrorCode TSSetDM(TS,DM);
753 PETSC_EXTERN PetscErrorCode TSGetDM(TS,DM*);
754 
755 PETSC_EXTERN PetscErrorCode SNESTSFormFunction(SNES,Vec,Vec,void*);
756 PETSC_EXTERN PetscErrorCode SNESTSFormJacobian(SNES,Vec,Mat*,Mat*,MatStructure*,void*);
757 
758 #endif
759