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