Actual source code: dlregissnes.c

petsc-3.6.1 2015-08-06
Report Typos and Errors
  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("SNESNGSEval",          SNES_CLASSID,&SNES_NGSEval);
 66:   PetscLogEventRegister("SNESNGSFuncEval",      SNES_CLASSID,&SNES_NGSFuncEval);
 67:   PetscLogEventRegister("SNESJacobianEval",     SNES_CLASSID,&SNES_JacobianEval);
 68:   PetscLogEventRegister("SNESLineSearch",       SNESLINESEARCH_CLASSID,&SNESLineSearch_Apply);
 69:   PetscLogEventRegister("SNESNPCSolve",         SNES_CLASSID,&SNES_NPCSolve);
 70:   /* Process info exclusions */
 71:   PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);
 72:   if (opt) {
 73:     PetscStrstr(logList, "snes", &className);
 74:     if (className) {
 75:       PetscInfoDeactivateClass(SNES_CLASSID);
 76:     }
 77:   }
 78:   /* Process summary exclusions */
 79:   PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);
 80:   if (opt) {
 81:     PetscStrstr(logList, "snes", &className);
 82:     if (className) {
 83:       PetscLogEventDeactivateClass(SNES_CLASSID);
 84:     }
 85:   }
 86:   PetscRegisterFinalize(SNESFinalizePackage);
 87:   return(0);
 88: }

 90: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
 93: /*
 94:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

 96:   This registers all of the SNES methods that are in the basic PETSc libpetscsnes library.

 98:  */
 99: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
100: {

104:   SNESInitializePackage();
105:   return(0);
106: }

108: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */