Actual source code: dlregissnes.c

petsc-3.8.3 2017-12-09
Report Typos and Errors

  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: .keywords: Petsc, destroy, package, mathematica
 14: .seealso: PetscFinalize()
 15: @*/
 16: PetscErrorCode  SNESFinalizePackage(void)
 17: {

 21:   PetscFunctionListDestroy(&SNESList);
 22:   PetscFunctionListDestroy(&SNESLineSearchList);
 23:   SNESPackageInitialized = PETSC_FALSE;
 24:   SNESRegisterAllCalled  = PETSC_FALSE;
 25:   SNESLineSearchRegisterAllCalled = PETSC_FALSE;
 26:   return(0);
 27: }

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

 34:   Level: developer

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

 47:   if (SNESPackageInitialized) return(0);
 48:   SNESPackageInitialized = PETSC_TRUE;
 49:   /* Initialize subpackages */
 50:   SNESMSInitializePackage();
 51:   /* Register Classes */
 52:   PetscClassIdRegister("SNES",&SNES_CLASSID);
 53:   PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
 54:   PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
 55:   /* Register Constructors */
 56:   SNESRegisterAll();
 57:   SNESLineSearchRegisterAll();
 58:   /* Register Events */
 59:   PetscLogEventRegister("SNESSolve",            SNES_CLASSID,&SNES_Solve);
 60:   PetscLogEventRegister("SNESFunctionEval",     SNES_CLASSID,&SNES_FunctionEval);
 61:   PetscLogEventRegister("SNESObjectiveEval",    SNES_CLASSID,&SNES_ObjectiveEval);
 62:   PetscLogEventRegister("SNESNGSEval",          SNES_CLASSID,&SNES_NGSEval);
 63:   PetscLogEventRegister("SNESNGSFuncEval",      SNES_CLASSID,&SNES_NGSFuncEval);
 64:   PetscLogEventRegister("SNESJacobianEval",     SNES_CLASSID,&SNES_JacobianEval);
 65:   PetscLogEventRegister("SNESLineSearch",       SNESLINESEARCH_CLASSID,&SNESLINESEARCH_Apply);
 66:   PetscLogEventRegister("SNESNPCSolve",         SNES_CLASSID,&SNES_NPCSolve);
 67:   /* Process info exclusions */
 68:   PetscOptionsGetString(NULL,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(NULL,NULL, "-log_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: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
 88: /*
 89:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

 93:  */
 94: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
 95: {

 99:   SNESInitializePackage();
100:   return(0);
101: }

103: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */