1 #ifdef PETSC_RCS_HEADER 2 static char vcid[] = "$Id: snesregi.c,v 1.23 1998/04/13 17:55:33 bsmith Exp curfman $"; 3 #endif 4 5 #include "src/snes/snesimpl.h" /*I "snes.h" I*/ 6 extern int SNESCreate_EQ_LS(SNES); 7 extern int SNESCreate_EQ_TR(SNES); 8 extern int SNESCreate_UM_TR(SNES); 9 extern int SNESCreate_UM_LS(SNES); 10 extern int SNESCreate_Test(SNES); 11 12 /*M 13 SNESRegister - Adds the method to the nonlinear solver package. 14 15 Synopsis: 16 SNESRegister(char *name_solver,char *path,char *name_create,int (*routine_create)(SNES)) 17 18 Input Parameters: 19 . name_solver - name of a new user-defined solver 20 . path - path (either absolute or relative) the library containing this solver 21 . name_create - name of routine to create method context 22 . routine_create - routine to create method context 23 24 Notes: 25 SNESRegister() may be called multiple times to add several user-defined solvers. 26 27 If dynamic libraries are used, then the fourth input argument (routine_create) 28 is ignored. 29 30 Sample usage: 31 SNESRegister("my_solver",/home/username/my_lib/lib/libg/solaris/mylib.a, 32 "MySolverCreate",MySolverCreate); 33 34 Then, your solver can be chosen with the procedural interface via 35 $ SNESSetType(snes,"my_solver") 36 $ or at runtime via the option 37 $ -snes_type my_solver 38 39 .keywords: SNES, nonlinear, register 40 41 .seealso: SNESRegisterAll(), SNESRegisterDestroy() 42 M*/ 43 44 #if defined(USE_DYNAMIC_LIBRARIES) 45 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,0) 46 #else 47 #define SNESRegister(a,b,c,d) SNESRegister_Private(a,b,c,d) 48 #endif 49 50 #undef __FUNC__ 51 #define __FUNC__ "SNESRegister_Private" 52 static int SNESRegister_Private(char *sname,char *path,char *name,int (*function)(SNES)) 53 { 54 char fullname[256]; 55 int ierr; 56 57 PetscFunctionBegin; 58 PetscStrcpy(fullname,path); PetscStrcat(fullname,":");PetscStrcat(fullname,name); 59 ierr = DLRegister(&SNESList,sname,fullname, (int (*)(void*))function);CHKERRQ(ierr); 60 PetscFunctionReturn(0); 61 } 62 63 /* 64 This is used by SNESSetType() to make sure that at least one 65 SNESRegisterAll() is called. In general, if there is more than one 66 DLL then SNESRegisterAll() may be called several times. 67 */ 68 extern int SNESRegisterAllCalled; 69 70 #undef __FUNC__ 71 #define __FUNC__ "SNESRegisterAll" 72 /*@C 73 SNESRegisterAll - Registers all of the nonlinear solver methods in the SNES package. 74 75 Not Collective 76 77 .keywords: SNES, register, all 78 79 .seealso: SNESRegisterDestroy() 80 @*/ 81 int SNESRegisterAll(char *path) 82 { 83 int ierr; 84 85 PetscFunctionBegin; 86 SNESRegisterAllCalled = 1; 87 88 ierr = SNESRegister("ls", path,"SNESCreate_EQ_LS",SNESCreate_EQ_LS);CHKERRQ(ierr); 89 ierr = SNESRegister("tr", path,"SNESCreate_EQ_TR",SNESCreate_EQ_TR);CHKERRQ(ierr); 90 ierr = SNESRegister("test", path,"SNESCreate_Test", SNESCreate_Test);CHKERRQ(ierr); 91 ierr = SNESRegister("umtr", path,"SNESCreate_UM_TR",SNESCreate_UM_TR);CHKERRQ(ierr); 92 ierr = SNESRegister("umls", path,"SNESCreate_UM_LS",SNESCreate_UM_LS);CHKERRQ(ierr); 93 94 PetscFunctionReturn(0); 95 } 96 97