Date: 2022-03-31T04:48:28+00:00

Actual source code: dlregissnes.c

      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: {
     17:   PetscFunctionListDestroy(&SNESList);
     18:   PetscFunctionListDestroy(&SNESLineSearchList);
     19:   SNESPackageInitialized = PETSC_FALSE;
     20:   SNESRegisterAllCalled  = PETSC_FALSE;
     21:   SNESLineSearchRegisterAllCalled = PETSC_FALSE;
     22:   return 0;
     23: }

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

     30:   Level: developer

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

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

     64:     classids[0] = SNES_CLASSID;
     65:     classids[1] = DMSNES_CLASSID;
     66:     classids[2] = SNESLINESEARCH_CLASSID;
     67:     PetscInfoProcessClass("snes", 1, classids);
     68:     PetscInfoProcessClass("dm", 1, &classids[1]);
     69:     PetscInfoProcessClass("sneslinesearch", 1, &classids[2]);
     70:   }
     71:   /* Process summary exclusions */
     72:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
     73:   if (opt) {
     74:     PetscStrInList("snes",logList,',',&pkg);
     75:     if (pkg) PetscLogEventExcludeClass(SNES_CLASSID);
     76:     PetscStrInList("dm",logList,',',&cls);
     77:     if (pkg || cls) PetscLogEventExcludeClass(DMSNES_CLASSID);
     78:     PetscStrInList("sneslinesearch",logList,',',&cls);
     79:     if (pkg || cls) PetscLogEventExcludeClass(SNESLINESEARCH_CLASSID);
     80:   }
     81:   /* Register package finalizer */
     82:   PetscRegisterFinalize(SNESFinalizePackage);
     83:   return 0;
     84: }

     86: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
     87: /*
     88:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

     92:  */
     93: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
     94: {
     95:   SNESInitializePackage();
     96:   return 0;
     97: }

     99: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */