Actual source code: dlregissnes.c
petsc-3.12.5 2020-03-29
2: #include <petsc/private/snesimpl.h>
3: #include <petsc/private/linesearchimpl.h>
5: static PetscBool SNESPackageInitialized = PETSC_FALSE;
7: /*@C
8: SNESFinalizePackage - This function destroys everything in the Petsc interface to the SNES package. It is
9: called from PetscFinalize().
11: Level: developer
13: .seealso: PetscFinalize()
14: @*/
15: PetscErrorCode SNESFinalizePackage(void)
16: {
20: PetscFunctionListDestroy(&SNESList);
21: PetscFunctionListDestroy(&SNESLineSearchList);
22: SNESPackageInitialized = PETSC_FALSE;
23: SNESRegisterAllCalled = PETSC_FALSE;
24: SNESLineSearchRegisterAllCalled = PETSC_FALSE;
25: return(0);
26: }
28: /*@C
29: SNESInitializePackage - This function initializes everything in the SNES package. It is called
30: from PetscDLLibraryRegister_petscsnes() when using dynamic libraries, and on the first call to SNESCreate()
31: when using shared or static libraries.
33: Level: developer
35: .seealso: PetscInitialize()
36: @*/
37: PetscErrorCode SNESInitializePackage(void)
38: {
39: char logList[256];
40: PetscBool opt,pkg,cls;
44: if (SNESPackageInitialized) return(0);
45: SNESPackageInitialized = PETSC_TRUE;
46: /* Initialize subpackages */
47: SNESMSInitializePackage();
48: /* Register Classes */
49: PetscClassIdRegister("SNES",&SNES_CLASSID);
50: PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
51: PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
52: /* Register Constructors */
53: SNESRegisterAll();
54: SNESLineSearchRegisterAll();
55: /* Register Events */
56: PetscLogEventRegister("SNESSolve", SNES_CLASSID,&SNES_Solve);
57: PetscLogEventRegister("SNESSetUp", SNES_CLASSID,&SNES_Setup);
58: PetscLogEventRegister("SNESFunctionEval", SNES_CLASSID,&SNES_FunctionEval);
59: PetscLogEventRegister("SNESObjectiveEval", SNES_CLASSID,&SNES_ObjectiveEval);
60: PetscLogEventRegister("SNESNGSEval", SNES_CLASSID,&SNES_NGSEval);
61: PetscLogEventRegister("SNESNGSFuncEval", SNES_CLASSID,&SNES_NGSFuncEval);
62: PetscLogEventRegister("SNESJacobianEval", SNES_CLASSID,&SNES_JacobianEval);
63: PetscLogEventRegister("SNESNPCSolve", SNES_CLASSID,&SNES_NPCSolve);
64: PetscLogEventRegister("SNESLineSearch", SNESLINESEARCH_CLASSID,&SNESLINESEARCH_Apply);
65: /* Process info exclusions */
66: PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
67: if (opt) {
68: PetscStrInList("snes",logList,',',&pkg);
69: if (pkg) {PetscInfoDeactivateClass(SNES_CLASSID);}
70: PetscStrInList("dm",logList,',',&cls);
71: if (pkg || cls) {PetscInfoDeactivateClass(DMSNES_CLASSID);}
72: PetscStrInList("sneslinesearch",logList,',',&cls);
73: if (pkg || cls) {PetscInfoDeactivateClass(SNESLINESEARCH_CLASSID);}
74: }
75: /* Process summary exclusions */
76: PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
77: if (opt) {
78: PetscStrInList("snes",logList,',',&pkg);
79: if (pkg) {PetscLogEventExcludeClass(SNES_CLASSID);}
80: PetscStrInList("dm",logList,',',&cls);
81: if (pkg || cls) {PetscLogEventExcludeClass(DMSNES_CLASSID);}
82: PetscStrInList("sneslinesearch",logList,',',&cls);
83: if (pkg || cls) {PetscLogEventExcludeClass(SNESLINESEARCH_CLASSID);}
84: }
85: /* Register package finalizer */
86: PetscRegisterFinalize(SNESFinalizePackage);
87: return(0);
88: }
90: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
91: /*
92: PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
94: This registers all of the SNES methods that are in the basic PETSc libpetscsnes library.
96: */
97: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
98: {
102: SNESInitializePackage();
103: return(0);
104: }
106: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */