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