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 TSType const char*
     31: #define TS_EULER           "euler"
     32: #define TS_BEULER          "beuler"
     33: #define TS_PSEUDO          "pseudo"
     34: #define TS_CRANK_NICHOLSON "crank-nicholson"
     35: #define TS_SUNDIALS        "sundials"
     36: #define TS_RUNGE_KUTTA     "runge-kutta"

     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 */

     50: EXTERN PetscErrorCode   TSInitializePackage(const char[]);

     52: EXTERN PetscErrorCode   TSCreate(MPI_Comm,TS*);
     53: EXTERN PetscErrorCode   TSDestroy(TS);

     55: EXTERN PetscErrorCode   TSSetProblemType(TS,TSProblemType);
     56: EXTERN PetscErrorCode   TSGetProblemType(TS,TSProblemType*);
     57: EXTERN PetscErrorCode   TSMonitorSet(TS,PetscErrorCode(*)(TS,PetscInt,PetscReal,Vec,void*),void *,PetscErrorCode (*)(void*));
     58: EXTERN PetscErrorCode   TSMonitorCancel(TS);

     60: EXTERN PetscErrorCode   TSSetOptionsPrefix(TS,const char[]);
     61: EXTERN PetscErrorCode   TSAppendOptionsPrefix(TS,const char[]);
     62: EXTERN PetscErrorCode   TSGetOptionsPrefix(TS,const char *[]);
     63: EXTERN PetscErrorCode   TSSetFromOptions(TS);
     64: EXTERN PetscErrorCode   TSSetUp(TS);

     66: EXTERN PetscErrorCode   TSSetSolution(TS,Vec);
     67: EXTERN PetscErrorCode   TSGetSolution(TS,Vec*);

     69: EXTERN PetscErrorCode   TSSetDuration(TS,PetscInt,PetscReal);
     70: EXTERN PetscErrorCode   TSGetDuration(TS,PetscInt*,PetscReal*);

     72: EXTERN PetscErrorCode   TSMonitorDefault(TS,PetscInt,PetscReal,Vec,void*);
     73: EXTERN PetscErrorCode   TSMonitorSolution(TS,PetscInt,PetscReal,Vec,void*);
     74: EXTERN PetscErrorCode   TSStep(TS,PetscInt *,PetscReal*);
     75: EXTERN PetscErrorCode   TSSolve(TS,Vec);

     78: EXTERN PetscErrorCode   TSSetInitialTimeStep(TS,PetscReal,PetscReal);
     79: EXTERN PetscErrorCode   TSGetTimeStep(TS,PetscReal*);
     80: EXTERN PetscErrorCode   TSGetTime(TS,PetscReal*);
     81: EXTERN PetscErrorCode   TSSetTime(TS,PetscReal);
     82: EXTERN PetscErrorCode   TSGetTimeStepNumber(TS,PetscInt*);
     83: EXTERN PetscErrorCode   TSSetTimeStep(TS,PetscReal);

     85: EXTERN PetscErrorCode   TSSetRHSFunction(TS,PetscErrorCode (*)(TS,PetscReal,Vec,Vec,void*),void*);
     86: EXTERN PetscErrorCode   TSSetMatrices(TS,Mat,PetscErrorCode (*)(TS,PetscReal,Mat*,Mat*,MatStructure*,void*),Mat,PetscErrorCode (*)(TS,PetscReal,Mat*,Mat*,MatStructure*,void*),MatStructure,void*);
     87: EXTERN PetscErrorCode   TSGetMatrices(TS,Mat*,Mat*,void**);
     88: EXTERN PetscErrorCode   TSSetRHSJacobian(TS,Mat,Mat,PetscErrorCode (*)(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*),void*);
     89: EXTERN PetscErrorCode   TSGetRHSJacobian(TS,Mat*,Mat*,void**);

     91: EXTERN PetscErrorCode   TSDefaultComputeJacobianColor(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);
     92: EXTERN PetscErrorCode   TSDefaultComputeJacobian(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*,void*);

     94: EXTERN PetscErrorCode   TSSetPreStep(TS, PetscErrorCode (*)(TS));
     95: EXTERN PetscErrorCode   TSSetUpdate(TS, PetscErrorCode (*)(TS, PetscReal, PetscReal *));
     96: EXTERN PetscErrorCode   TSSetPostStep(TS, PetscErrorCode (*)(TS));
     97: EXTERN PetscErrorCode   TSDefaultPreStep(TS);
     98: EXTERN PetscErrorCode   TSDefaultUpdate(TS, PetscReal, PetscReal *);
     99: EXTERN PetscErrorCode   TSDefaultPostStep(TS);

    101: EXTERN PetscErrorCode   TSPseudoSetTimeStep(TS,PetscErrorCode(*)(TS,PetscReal*,void*),void*);
    102: EXTERN PetscErrorCode   TSPseudoDefaultTimeStep(TS,PetscReal*,void*);
    103: EXTERN PetscErrorCode   TSPseudoComputeTimeStep(TS,PetscReal *);

    105: EXTERN PetscErrorCode   TSPseudoSetVerifyTimeStep(TS,PetscErrorCode(*)(TS,Vec,void*,PetscReal*,PetscTruth*),void*);
    106: EXTERN PetscErrorCode   TSPseudoDefaultVerifyTimeStep(TS,Vec,void*,PetscReal*,PetscTruth*);
    107: EXTERN PetscErrorCode   TSPseudoVerifyTimeStep(TS,Vec,PetscReal*,PetscTruth*);
    108: EXTERN PetscErrorCode   TSPseudoSetTimeStepIncrement(TS,PetscReal);
    109: EXTERN PetscErrorCode   TSPseudoIncrementDtFromInitialDt(TS);

    111: EXTERN PetscErrorCode   TSComputeRHSFunction(TS,PetscReal,Vec,Vec);
    112: EXTERN PetscErrorCode   TSComputeRHSJacobian(TS,PetscReal,Vec,Mat*,Mat*,MatStructure*);

    114: /* Dynamic creation and loading functions */
    117: EXTERN PetscErrorCode   TSGetType(TS,TSType*);
    118: EXTERN PetscErrorCode   TSSetType(TS,TSType);
    119: EXTERN PetscErrorCode   TSRegister(const char[], const char[], const char[], PetscErrorCode (*)(TS));
    120: EXTERN PetscErrorCode   TSRegisterAll(const char[]);
    121: EXTERN PetscErrorCode   TSRegisterDestroy(void);

    123: /*MC
    124:   TSRegisterDynamic - Adds a creation method to the TS package.

    126:   Synopsis:
    127:   PetscErrorCode TSRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(TS))

    129:   Not Collective

    131:   Input Parameters:
    132: + name        - The name of a new user-defined creation routine
    133: . path        - The path (either absolute or relative) of the library containing this routine
    134: . func_name   - The name of the creation routine
    135: - create_func - The creation routine itself

    137:   Notes:
    138:   TSRegisterDynamic() may be called multiple times to add several user-defined tses.

    140:   If dynamic libraries are used, then the fourth input argument (create_func) is ignored.

    142:   Sample usage:
    143: .vb
    144:   TSRegisterDynamic("my_ts", "/home/username/my_lib/lib/libO/solaris/libmy.a", "MyTSCreate", MyTSCreate);
    145: .ve

    147:   Then, your ts type can be chosen with the procedural interface via
    148: .vb
    149:     TSCreate(MPI_Comm, TS *);
    150:     TSSetType(vec, "my_ts")
    151: .ve
    152:   or at runtime via the option
    153: .vb
    154:     -ts_type my_ts
    155: .ve

    157:   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
    158:         If your function is not being put into a shared library then use TSRegister() instead

    160:   Level: advanced

    162: .keywords: TS, register
    163: .seealso: TSRegisterAll(), TSRegisterDestroy()
    164: M*/
    165: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
    166: #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,0)
    167: #else
    168: #define TSRegisterDynamic(a,b,c,d) TSRegister(a,b,c,d)
    169: #endif

    171: EXTERN PetscErrorCode   TSGetSNES(TS,SNES*);
    172: EXTERN PetscErrorCode   TSGetKSP(TS,KSP*);

    174: EXTERN PetscErrorCode   TSView(TS,PetscViewer);
    175: EXTERN PetscErrorCode   TSViewFromOptions(TS,const char[]);

    177: EXTERN PetscErrorCode   TSSetApplicationContext(TS,void *);
    178: EXTERN PetscErrorCode   TSGetApplicationContext(TS,void **);

    180: EXTERN PetscErrorCode   TSMonitorLGCreate(const char[],const char[],int,int,int,int,PetscDrawLG *);
    181: EXTERN PetscErrorCode   TSMonitorLG(TS,PetscInt,PetscReal,Vec,void *);
    182: EXTERN PetscErrorCode   TSMonitorLGDestroy(PetscDrawLG);

    184: /*
    185:        PETSc interface to Sundials
    186: */
    187: #ifdef PETSC_HAVE_SUNDIALS
    188: typedef enum { SUNDIALS_ADAMS=1,SUNDIALS_BDF=2} TSSundialsLmmType;
    190: typedef enum { SUNDIALS_MODIFIED_GS = 1,SUNDIALS_CLASSICAL_GS = 2 } TSSundialsGramSchmidtType;
    192: EXTERN PetscErrorCode   TSSundialsSetType(TS,TSSundialsLmmType);
    193: EXTERN PetscErrorCode   TSSundialsGetPC(TS,PC*);
    194: EXTERN PetscErrorCode   TSSundialsSetTolerance(TS,PetscReal,PetscReal);
    195: EXTERN PetscErrorCode   TSSundialsGetIterations(TS,PetscInt *,PetscInt *);
    196: EXTERN PetscErrorCode   TSSundialsSetGramSchmidtType(TS,TSSundialsGramSchmidtType);
    197: EXTERN PetscErrorCode   TSSundialsSetGMRESRestart(TS,PetscInt);
    198: EXTERN PetscErrorCode   TSSundialsSetLinearTolerance(TS,PetscReal);
    199: EXTERN PetscErrorCode   TSSundialsSetExactFinalTime(TS,PetscTruth);
    200: EXTERN PetscErrorCode   TSSundialsGetParameters(TS,PetscInt *,long*[],double*[]);
    201: #endif

    203: EXTERN PetscErrorCode   TSRKSetTolerance(TS,PetscReal);

    206: #endif