Actual source code: dlregissnes.c

petsc-master 2020-08-13
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: .seealso: PetscFinalize()
 14: @*/
 15: PetscErrorCode  SNESFinalizePackage(void)
 16: {

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

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

 33:   Level: developer

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

 44:   if (SNESPackageInitialized) return(0);
 45:   SNESPackageInitialized = PETSC_TRUE;
 46:   /* Initialize subpackages */
 47:   SNESMSInitializePackage();
 48:   /* Register Classes */
 49:   PetscClassIdRegister("SNES",&SNES_CLASSID);
 50:   PetscClassIdRegister("DMSNES",&DMSNES_CLASSID);
 51:   PetscClassIdRegister("SNESLineSearch",&SNESLINESEARCH_CLASSID);
 52:   /* Register Constructors */
 53:   SNESRegisterAll();
 54:   SNESLineSearchRegisterAll();
 55:   /* Register Events */
 56:   PetscLogEventRegister("SNESSolve",            SNES_CLASSID,&SNES_Solve);
 57:   PetscLogEventRegister("SNESSetUp",            SNES_CLASSID,&SNES_Setup);
 58:   PetscLogEventRegister("SNESFunctionEval",     SNES_CLASSID,&SNES_FunctionEval);
 59:   PetscLogEventRegister("SNESObjectiveEval",    SNES_CLASSID,&SNES_ObjectiveEval);
 60:   PetscLogEventRegister("SNESNGSEval",          SNES_CLASSID,&SNES_NGSEval);
 61:   PetscLogEventRegister("SNESNGSFuncEval",      SNES_CLASSID,&SNES_NGSFuncEval);
 62:   PetscLogEventRegister("SNESJacobianEval",     SNES_CLASSID,&SNES_JacobianEval);
 63:   PetscLogEventRegister("SNESNPCSolve",         SNES_CLASSID,&SNES_NPCSolve);
 64:   PetscLogEventRegister("SNESLineSearch",       SNESLINESEARCH_CLASSID,&SNESLINESEARCH_Apply);
 65:   /* Process Info */
 66:   {
 67:     PetscClassId  classids[3];

 69:     classids[0] = SNES_CLASSID;
 70:     classids[1] = DMSNES_CLASSID;
 71:     classids[2] = SNESLINESEARCH_CLASSID;
 72:     PetscInfoProcessClass("snes", 1, classids);
 73:     PetscInfoProcessClass("dm", 1, &classids[1]);
 74:     PetscInfoProcessClass("sneslinesearch", 1, &classids[2]);
 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 */