Actual source code: dlregissnes.c
petsc-3.7.7 2017-09-25
2: #include <petsc/private/snesimpl.h>
3: #include <petsc/private/linesearchimpl.h>
5: static PetscBool SNESPackageInitialized = PETSC_FALSE;
9: /*@C
10: SNESFinalizePackage - This function destroys everything in the Petsc interface to the SNES package. It is
11: called from PetscFinalize().
13: Level: developer
15: .keywords: Petsc, destroy, package, mathematica
16: .seealso: PetscFinalize()
17: @*/
18: PetscErrorCode SNESFinalizePackage(void)
19: {
23: PetscFunctionListDestroy(&SNESList);
24: PetscFunctionListDestroy(&SNESLineSearchList);
25: SNESPackageInitialized = PETSC_FALSE;
26: SNESRegisterAllCalled = PETSC_FALSE;
27: SNESLineSearchRegisterAllCalled = PETSC_FALSE;
28: return(0);
29: }
33: /*@C
34: SNESInitializePackage - This function initializes everything in the SNES package. It is called
35: from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to SNESCreate()
36: when using static libraries.
38: Level: developer
40: .keywords: SNES, initialize, package
41: .seealso: PetscInitialize()
42: @*/
43: PetscErrorCode SNESInitializePackage(void)
44: {
45: char logList[256];
46: char *className;
47: PetscBool opt;
51: if (SNESPackageInitialized) return(0);
52: SNESPackageInitialized = PETSC_TRUE;
53: /* Initialize subpackages */
54: SNESMSInitializePackage();
55: /* Register Classes */
56: PetscClassIdRegister("SNES",&SNES_CLASSID);
57: PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
58: PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
59: /* Register Constructors */
60: SNESRegisterAll();
61: SNESLineSearchRegisterAll();
62: /* Register Events */
63: PetscLogEventRegister("SNESSolve", SNES_CLASSID,&SNES_Solve);
64: PetscLogEventRegister("SNESFunctionEval", SNES_CLASSID,&SNES_FunctionEval);
65: PetscLogEventRegister("SNESObjectiveEval", SNES_CLASSID,&SNES_ObjectiveEval);
66: PetscLogEventRegister("SNESNGSEval", SNES_CLASSID,&SNES_NGSEval);
67: PetscLogEventRegister("SNESNGSFuncEval", SNES_CLASSID,&SNES_NGSFuncEval);
68: PetscLogEventRegister("SNESJacobianEval", SNES_CLASSID,&SNES_JacobianEval);
69: PetscLogEventRegister("SNESLineSearch", SNESLINESEARCH_CLASSID,&SNESLineSearch_Apply);
70: PetscLogEventRegister("SNESNPCSolve", SNES_CLASSID,&SNES_NPCSolve);
71: /* Process info exclusions */
72: PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);
73: if (opt) {
74: PetscStrstr(logList, "snes", &className);
75: if (className) {
76: PetscInfoDeactivateClass(SNES_CLASSID);
77: }
78: }
79: /* Process summary exclusions */
80: PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);
81: if (opt) {
82: PetscStrstr(logList, "snes", &className);
83: if (className) {
84: PetscLogEventDeactivateClass(SNES_CLASSID);
85: }
86: }
87: PetscRegisterFinalize(SNESFinalizePackage);
88: return(0);
89: }
91: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
94: /*
95: PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
97: This registers all of the SNES methods that are in the basic PETSc libpetscsnes library.
99: */
100: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
101: {
105: SNESInitializePackage();
106: return(0);
107: }
109: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */