Actual source code: dlregissnes.c

petsc-3.3-p7 2013-05-11
  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: {
 21:   SNESPackageInitialized = PETSC_FALSE;
 22:   SNESRegisterAllCalled  = PETSC_FALSE;
 23:   SNESList               = PETSC_NULL;
 24:   SNESLineSearchList     = PETSC_NULL;
 25:   return(0);
 26: }

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

 35:   Input Parameter:
 36:   path - The dynamic library path, or PETSC_NULL

 38:   Level: developer

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

 51:   if (SNESPackageInitialized) return(0);
 52:   SNESPackageInitialized = PETSC_TRUE;
 53:   /* Initialize subpackages */
 54:   SNESMSInitializePackage(path);
 55:   /* Register Classes */
 56:   PetscClassIdRegister("SNES",&SNES_CLASSID);
 57:   PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
 58:   /* Register Constructors */
 59:   SNESRegisterAll(path);
 60:   SNESLineSearchRegisterAll(path);
 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:   /* Process info exclusions */
 68:   PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
 69:   if (opt) {
 70:     PetscStrstr(logList, "snes", &className);
 71:     if (className) {
 72:       PetscInfoDeactivateClass(SNES_CLASSID);
 73:     }
 74:   }
 75:   /* Process summary exclusions */
 76:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
 77:   if (opt) {
 78:     PetscStrstr(logList, "snes", &className);
 79:     if (className) {
 80:       PetscLogEventDeactivateClass(SNES_CLASSID);
 81:     }
 82:   }
 83:   PetscRegisterFinalize(SNESFinalizePackage);
 84:   return(0);
 85: }

 87: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
 88: EXTERN_C_BEGIN
 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:   Input Parameter:
 97:   path - library path

 99:  */
100: PetscErrorCode  PetscDLLibraryRegister_petscsnes(const char path[])
101: {

105:   SNESInitializePackage(path);
106:   return(0);
107: }
108: EXTERN_C_END

110: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */