Actual source code: dlregissnes.c

petsc-3.11.4 2019-09-28
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_petscsnes() when using dynamic libraries, and on the first call to SNESCreate()
 32:   when using shared or static libraries.

 34:   Level: developer

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

 46:   if (SNESPackageInitialized) return(0);
 47:   SNESPackageInitialized = PETSC_TRUE;
 48:   /* Initialize subpackages */
 49:   SNESMSInitializePackage();
 50:   /* Register Classes */
 51:   PetscClassIdRegister("SNES",&SNES_CLASSID);
 52:   PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
 53:   PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
 54:   /* Register Constructors */
 55:   SNESRegisterAll();
 56:   SNESLineSearchRegisterAll();
 57:   /* Register Events */
 58:   PetscLogEventRegister("SNESSolve",            SNES_CLASSID,&SNES_Solve);
 59:   PetscLogEventRegister("SNESFunctionEval",     SNES_CLASSID,&SNES_FunctionEval);
 60:   PetscLogEventRegister("SNESObjectiveEval",    SNES_CLASSID,&SNES_ObjectiveEval);
 61:   PetscLogEventRegister("SNESNGSEval",          SNES_CLASSID,&SNES_NGSEval);
 62:   PetscLogEventRegister("SNESNGSFuncEval",      SNES_CLASSID,&SNES_NGSFuncEval);
 63:   PetscLogEventRegister("SNESJacobianEval",     SNES_CLASSID,&SNES_JacobianEval);
 64:   PetscLogEventRegister("SNESNPCSolve",         SNES_CLASSID,&SNES_NPCSolve);
 65:   PetscLogEventRegister("SNESLineSearch",       SNESLINESEARCH_CLASSID,&SNESLINESEARCH_Apply);
 66:   /* Process info exclusions */
 67:   PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);
 68:   if (opt) {
 69:     PetscStrInList("snes",logList,',',&pkg);
 70:     if (pkg) {PetscInfoDeactivateClass(SNES_CLASSID);}
 71:     PetscStrInList("dm",logList,',',&cls);
 72:     if (pkg || cls) {PetscInfoDeactivateClass(DMSNES_CLASSID);}
 73:     PetscStrInList("sneslinesearch",logList,',',&cls);
 74:     if (pkg || cls) {PetscInfoDeactivateClass(SNESLINESEARCH_CLASSID);}
 75:   }
 76:   /* Process summary exclusions */
 77:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
 78:   if (opt) {
 79:     PetscStrInList("snes",logList,',',&pkg);
 80:     if (pkg) {PetscLogEventExcludeClass(SNES_CLASSID);}
 81:     PetscStrInList("dm",logList,',',&cls);
 82:     if (pkg || cls) {PetscLogEventExcludeClass(DMSNES_CLASSID);}
 83:     PetscStrInList("sneslinesearch",logList,',',&cls);
 84:     if (pkg || cls) {PetscLogEventExcludeClass(SNESLINESEARCH_CLASSID);}
 85:   }
 86:   /* Register package finalizer */
 87:   PetscRegisterFinalize(SNESFinalizePackage);
 88:   return(0);
 89: }

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

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

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

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

107: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */