Actual source code: dlregissnes.c

petsc-3.4.5 2014-06-29
  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:   return(0);
 28: }

 32: /*@C
 33:   SNESInitializePackage - This function initializes everything in the SNES package. It is called
 34:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to SNESCreate()
 35:   when using static libraries.

 37:   Level: developer

 39: .keywords: SNES, initialize, package
 40: .seealso: PetscInitialize()
 41: @*/
 42: PetscErrorCode  SNESInitializePackage(void)
 43: {
 44:   char           logList[256];
 45:   char           *className;
 46:   PetscBool      opt;

 50:   if (SNESPackageInitialized) return(0);
 51:   SNESPackageInitialized = PETSC_TRUE;
 52:   /* Initialize subpackages */
 53:   SNESMSInitializePackage();
 54:   /* Register Classes */
 55:   PetscClassIdRegister("SNES",&SNES_CLASSID);
 56:   PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
 57:   PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
 58:   /* Register Constructors */
 59:   SNESRegisterAll();
 60:   SNESLineSearchRegisterAll();
 61:   /* Register Events */
 62:   PetscLogEventRegister("SNESSolve",            SNES_CLASSID,&SNES_Solve);
 63:   PetscLogEventRegister("SNESFunctionEval",     SNES_CLASSID,&SNES_FunctionEval);
 64:   PetscLogEventRegister("SNESGSEval",           SNES_CLASSID,&SNES_GSEval);
 65:   PetscLogEventRegister("SNESJacobianEval",     SNES_CLASSID,&SNES_JacobianEval);
 66:   PetscLogEventRegister("SNESLineSearch",       SNESLINESEARCH_CLASSID,&SNESLineSearch_Apply);
 67:   PetscLogEventRegister("SNESNPCSolve",         SNES_CLASSID,&SNES_NPCSolve);
 68:   /* Process info exclusions */
 69:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
 70:   if (opt) {
 71:     PetscStrstr(logList, "snes", &className);
 72:     if (className) {
 73:       PetscInfoDeactivateClass(SNES_CLASSID);
 74:     }
 75:   }
 76:   /* Process summary exclusions */
 77:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
 78:   if (opt) {
 79:     PetscStrstr(logList, "snes", &className);
 80:     if (className) {
 81:       PetscLogEventDeactivateClass(SNES_CLASSID);
 82:     }
 83:   }
 84:   PetscRegisterFinalize(SNESFinalizePackage);
 85:   return(0);
 86: }

 88: #if defined(PETSC_USE_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_USE_DYNAMIC_LIBRARIES */