1 #ifdef PETSC_RCS_HEADER 2 static char vcid[] = "$Id: tsregall.c,v 1.15 1998/04/13 17:50:17 bsmith Exp curfman $"; 3 #endif 4 5 #include "src/ts/tsimpl.h" /*I "ts.h" I*/ 6 extern int TSCreate_Euler(TS); 7 extern int TSCreate_BEuler(TS); 8 extern int TSCreate_Pseudo(TS); 9 extern int TSCreate_PVode(TS); 10 11 /*M 12 TSRegister - Adds a method to the timestepping solver package. 13 14 Synopsis: 15 TSRegister(char *name_solver,char *path,char *name_create,int (*routine_create)(TS)) 16 17 Input Parameters: 18 . name_solver - name of a new user-defined solver 19 . path - path (either absolute or relative) the library containing this solver 20 . name_create - name of routine to create method context 21 . routine_create - routine to create method context 22 23 Notes: 24 TSRegister() may be called multiple times to add several user-defined solvers. 25 26 If dynamic libraries are used, then the fourth input argument (routine_create) 27 is ignored. 28 29 Sample usage: 30 TSRegister("my_solver",/home/username/my_lib/lib/libO/solaris/mylib.a, 31 "MySolverCreate",MySolverCreate); 32 33 Then, your solver can be chosen with the procedural interface via 34 $ TSSetType(ts,"my_solver") 35 $ or at runtime via the option 36 $ -ts_type my_solver 37 38 .keywords: TS, register 39 40 .seealso: TSRegisterAll(), TSRegisterDestroy() 41 M*/ 42 43 #if defined(USE_DYNAMIC_LIBRARIES) 44 #define TSRegister(a,b,c,d) TSRegister_Private(a,b,c,0) 45 #else 46 #define TSRegister(a,b,c,d) TSRegister_Private(a,b,c,d) 47 #endif 48 49 #undef __FUNC__ 50 #define __FUNC__ "TSRegister_Private" 51 static int TSRegister_Private(char *sname,char *path,char *name,int (*function)(TS)) 52 { 53 char fullname[256]; 54 55 PetscFunctionBegin; 56 PetscStrcpy(fullname,path); PetscStrcat(fullname,":"); PetscStrcat(fullname,name); 57 DLRegister(&TSList,sname,fullname, (int (*)(void*))function); 58 PetscFunctionReturn(0); 59 } 60 61 #undef __FUNC__ 62 #define __FUNC__ "TSRegisterAll" 63 /*@C 64 TSRegisterAll - Registers all of the timesteppers in the TS 65 package. 66 67 Not Collective 68 69 .keywords: TS, timestepper, register, all 70 71 .seealso: TSRegisterDestroy() 72 @*/ 73 int TSRegisterAll(char *path) 74 { 75 PetscFunctionBegin; 76 TSRegisterAllCalled = 1; 77 78 TSRegister(TS_EULER, path,"TSCreate_Euler", TSCreate_Euler); 79 TSRegister(TS_BEULER, path,"TSCreate_BEuler",TSCreate_BEuler); 80 TSRegister(TS_PSEUDO, path,"TSCreate_Pseudo",TSCreate_Pseudo); 81 #if defined(HAVE_PVODE) && !defined(__cplusplus) 82 TSRegister(TS_PVODE, path,"TSCreate_PVode", TSCreate_PVode); 83 #endif 84 PetscFunctionReturn(0); 85 } 86