Actual source code: tsimpl.h
2: #ifndef __TSIMPL_H
5: #include petscts.h
7: /*
8: Timesteping context.
9: General case: U_t = F(t,U) <-- the right-hand-side function
10: Linear case: U_t = A(t) U <-- the right-hand-side matrix
11: Linear (no time) case: U_t = A U <-- the right-hand-side matrix
12: */
14: /*
15: Maximum number of monitors you can run with a single TS
16: */
17: #define MAXTSMONITORS 5
19: struct _TSOps {
20: PetscErrorCode (*rhsmatrix)(TS, PetscReal, Mat *, Mat *, MatStructure *, void *);
21: PetscErrorCode (*rhsfunction)(TS, PetscReal, Vec, Vec, void *);
22: PetscErrorCode (*rhsjacobian)(TS, PetscReal, Vec, Mat *, Mat *, MatStructure *, void *);
23: PetscErrorCode (*applymatrixbc)(TS, Mat, Mat, void *);
24: PetscErrorCode (*rhsbc)(TS, PetscReal, Vec, void *);
25: PetscErrorCode (*applyrhsbc)(TS, Vec, void *);
26: PetscErrorCode (*applysolbc)(TS, Vec, void *);
27: PetscErrorCode (*prestep)(TS);
28: PetscErrorCode (*update)(TS, PetscReal, PetscReal *);
29: PetscErrorCode (*poststep)(TS);
30: PetscErrorCode (*reform)(TS);
31: PetscErrorCode (*reallocate)(TS);
32: PetscErrorCode (*setup)(TS);
33: PetscErrorCode (*step)(TS,PetscInt *, PetscReal *);
34: PetscErrorCode (*setfromoptions)(TS);
35: PetscErrorCode (*printhelp)(TS, char *);
36: PetscErrorCode (*destroy)(TS);
37: PetscErrorCode (*view)(TS, PetscViewer);
38: };
40: struct _p_TS {
41: PETSCHEADER(struct _TSOps);
42: TSProblemType problem_type;
43: Vec vec_sol, vec_sol_always;
45: /* ---------------- User (or PETSc) Provided stuff ---------------------*/
46: PetscErrorCode (*monitor[MAXTSMONITORS])(TS,PetscInt,PetscReal,Vec,void*); /* returns control to user after */
47: PetscErrorCode (*mdestroy[MAXTSMONITORS])(void*);
48: void *monitorcontext[MAXTSMONITORS]; /* residual calculation, allows user */
49: PetscInt numbermonitors; /* to, for instance, print residual norm, etc. */
51: /* Identifies this as a grid TS structure */
52: PetscTruth isGTS; /* This problem arises from an underlying grid */
53: PetscTruth *isExplicit; /* Indicates which fields have explicit time dependence */
54: PetscInt *Iindex; /* The index of the identity for each time dependent field */
56: /* ---------------------Linear Iteration---------------------------------*/
57: KSP ksp;
58: Mat A, B; /* user provided matrix and preconditioner */
60: /* ---------------------Nonlinear Iteration------------------------------*/
61: SNES snes;
62: void *funP;
63: void *jacP;
64: void *bcP;
67: /* --- Data that is unique to each particular solver --- */
68: PetscInt setupcalled; /* true if setup has been called */
69: void *data; /* implementationspecific data */
70: void *user; /* user context */
72: /* ------------------ Parameters -------------------------------------- */
73: PetscInt max_steps; /* max number of steps */
74: PetscReal max_time; /* max time allowed */
75: PetscReal time_step; /* current time increment */
76: PetscReal time_step_old; /* previous time increment */
77: PetscReal initial_time_step; /* initial time increment */
78: PetscInt steps; /* steps taken so far */
79: PetscReal ptime; /* time taken so far */
80: PetscInt linear_its; /* total number of linear solver iterations */
81: PetscInt nonlinear_its; /* total number of nonlinear solver iterations */
83: /* ------------------- Default work-area management ------------------ */
84: PetscInt nwork;
85: Vec *work;
86: };
88: EXTERN PetscErrorCode TSMonitor(TS,PetscInt,PetscReal,Vec);
89: EXTERN PetscErrorCode TSComputeRHSBoundaryConditions(TS,PetscReal,Vec);
90: EXTERN PetscErrorCode TSScaleShiftMatrices(TS,Mat,Mat,MatStructure);
92: #endif