Actual source code: petscts.h
1: /*
2: User interface for the timestepping package. This is package
3: is for use in solving time-dependent PDEs.
4: */
7: #include petscsnes.h
10: /*S
11: TS - Abstract PETSc object that manages all time-steppers (ODE integrators)
13: Level: beginner
15: Concepts: ODE solvers
17: .seealso: TSCreate(), TSSetType(), TSType, SNES, KSP, PC
18: S*/
19: typedef struct _p_TS* TS;
21: /*E
22: TSType - String with the name of a PETSc TS method or the creation function
23: with an optional dynamic library name, for example
24: http://www.mcs.anl.gov/petsc/lib.a:mytscreate()
26: Level: beginner
28: .seealso: TSSetType(), TS
29: E*/
30: #define TS_EULER "euler"
31: #define TS_BEULER "beuler"
32: #define TS_PSEUDO "pseudo"
33: #define TS_CRANK_NICHOLSON "crank-nicholson"
34: #define TS_PVODE "pvode"
35: #define TS_RUNGE_KUTTA "runge-kutta"
36: #define TSType char*
38: /*E
39: TSProblemType - Determines the type of problem this TS object is to be used to solve
41: Level: beginner
43: .seealso: TSCreate()
44: E*/
45: typedef enum {TS_LINEAR,TS_NONLINEAR} TSProblemType;
47: /* Logging support */
51: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSInitializePackage(const char[]);
53: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSCreate(MPI_Comm,TS*);
54: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDestroy(TS);
56: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetProblemType(TS,TSProblemType);
57: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetProblemType(TS,TSProblemType*);
58: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetMonitor(TS,PetscErrorCode(*)(TS,PetscInt,PetscReal,Vec,void*),void *,PetscErrorCode (*)(void*));
59: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSClearMonitor(TS);
61: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetOptionsPrefix(TS,const char[]);
62: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSAppendOptionsPrefix(TS,const char[]);
63: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetOptionsPrefix(TS,const char *[]);
64: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetFromOptions(TS);
65: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetUp(TS);
67: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetSolution(TS,Vec);
68: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetSolution(TS,Vec*);
70: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetDuration(TS,PetscInt,PetscReal);
71: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetDuration(TS,PetscInt*,PetscReal*);
73: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultMonitor(TS,PetscInt,PetscReal,Vec,void*);
74: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSVecViewMonitor(TS,PetscInt,PetscReal,Vec,void*);
75: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSStep(TS,PetscInt *,PetscReal*);
77: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetInitialTimeStep(TS,PetscReal,PetscReal);
78: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetTimeStep(TS,PetscReal*);
79: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetTime(TS,PetscReal*);
80: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetTimeStepNumber(TS,PetscInt*);
81: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetTimeStep(TS,PetscReal);
83: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetRHSFunction(TS,PetscErrorCode (*)(TS,PetscReal,Vec,Vec,void*),void*);
84: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetRHSMatrix(TS,Mat,Mat,PetscErrorCode (*)(TS,PetscReal,Mat*,Mat*,MatStructure*,void*),void*);
85: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetRHSJacobian(TS,Mat,Mat,PetscErrorCode (*)(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*),void*);
86: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetRHSBoundaryConditions(TS,PetscErrorCode (*)(TS,PetscReal,Vec,void*),void*);
88: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultComputeJacobianColor(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);
89: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultComputeJacobian(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);
91: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetRHSMatrix(TS,Mat*,Mat*,void**);
92: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetRHSJacobian(TS,Mat*,Mat*,void**);
94: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetSystemMatrixBC(TS, PetscErrorCode (*)(TS, Mat, Mat, void *));
95: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetSolutionBC(TS, PetscErrorCode (*)(TS, Vec, void *));
96: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetPreStep(TS, PetscErrorCode (*)(TS));
97: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetUpdate(TS, PetscErrorCode (*)(TS, PetscReal, PetscReal *));
98: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetPostStep(TS, PetscErrorCode (*)(TS));
99: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultRhsBC(TS, Vec, void *);
100: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultSystemMatrixBC(TS, Mat, Mat, void *);
101: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultSolutionBC(TS, Vec, void *);
102: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultPreStep(TS);
103: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultUpdate(TS, PetscReal, PetscReal *);
104: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSDefaultPostStep(TS);
105: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetIdentity(TS, PetscErrorCode (*)(TS, double, Mat *, void *));
107: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoSetTimeStep(TS,PetscErrorCode(*)(TS,PetscReal*,void*),void*);
108: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoDefaultTimeStep(TS,PetscReal*,void*);
109: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoComputeTimeStep(TS,PetscReal *);
111: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoSetVerifyTimeStep(TS,PetscErrorCode(*)(TS,Vec,void*,PetscReal*,PetscTruth*),void*);
112: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoDefaultVerifyTimeStep(TS,Vec,void*,PetscReal*,PetscTruth*);
113: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoVerifyTimeStep(TS,Vec,PetscReal*,PetscTruth*);
114: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoSetTimeStepIncrement(TS,PetscReal);
115: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPseudoIncrementDtFromInitialDt(TS);
117: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSComputeRHSFunction(TS,PetscReal,Vec,Vec);
118: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSComputeRHSBoundaryConditions(TS,PetscReal,Vec);
119: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSComputeRHSJacobian(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*);
121: /* Dynamic creation and loading functions */
124: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetType(TS,TSType*);
125: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetType(TS,const TSType);
126: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSRegister(const char[], const char[], const char[], PetscErrorCode (*)(TS));
127: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSRegisterAll(const char[]);
128: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSRegisterDestroy(void);
130: /*MC
131: TSRegisterDynamic - Adds a creation method to the TS package.
133: Synopsis:
134: PetscErrorCode TSRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(TS))
136: Not Collective
138: Input Parameters:
139: + name - The name of a new user-defined creation routine
140: . path - The path (either absolute or relative) of the library containing this routine
141: . func_name - The name of the creation routine
142: - create_func - The creation routine itself
144: Notes:
145: TSRegisterDynamic() may be called multiple times to add several user-defined tses.
147: If dynamic libraries are used, then the fourth input argument (create_func) is ignored.
149: Sample usage:
150: .vb
151: TSRegisterDynamic("my_ts", "/home/username/my_lib/lib/libO/solaris/libmy.a", "MyTSCreate", MyTSCreate);
152: .ve
154: Then, your ts type can be chosen with the procedural interface via
155: .vb
156: TSCreate(MPI_Comm, TS *);
157: TSSetType(vec, "my_ts")
158: .ve
159: or at runtime via the option
160: .vb
161: -ts_type my_ts
162: .ve
164: Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
165: If your function is not being put into a shared library then use TSRegister() instead
167: Level: advanced
169: .keywords: TS, register
170: .seealso: TSRegisterAll(), TSRegisterDestroy()
171: M*/
172: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
173: #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,0)
174: #else
175: #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,d)
176: #endif
178: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetSNES(TS,SNES*);
179: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetKSP(TS,KSP*);
181: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSView(TS,PetscViewer);
182: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSViewFromOptions(TS,const char[]);
184: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSSetApplicationContext(TS,void *);
185: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSGetApplicationContext(TS,void **);
187: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSLGMonitorCreate(const char[],const char[],int,int,int,int,PetscDrawLG *);
188: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSLGMonitor(TS,PetscInt,PetscReal,Vec,void *);
189: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSLGMonitorDestroy(PetscDrawLG);
191: /*
192: PETSc interface to PVode
193: */
194: #define PVODE_UNMODIFIED_GS PVODE_CLASSICAL_GS
195: typedef enum { PVODE_ADAMS,PVODE_BDF } TSPVodeType;
196: typedef enum { PVODE_MODIFIED_GS = 0,PVODE_CLASSICAL_GS = 1 } TSPVodeGramSchmidtType;
197: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetType(TS,TSPVodeType);
198: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeGetPC(TS,PC*);
199: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetTolerance(TS,PetscReal,PetscReal);
200: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeGetIterations(TS,PetscInt *,PetscInt *);
201: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetGramSchmidtType(TS,TSPVodeGramSchmidtType);
202: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetGMRESRestart(TS,PetscInt);
203: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetLinearTolerance(TS,PetscReal);
204: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeSetExactFinalTime(TS,PetscTruth);
205: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSPVodeGetParameters(TS,PetscInt *,long int*[],double*[]);
207: EXTERN PetscErrorCode PETSCTS_DLLEXPORT TSRKSetTolerance(TS,PetscReal);
210: #endif