Date: 2022-08-02T03:13:17+00:00

Actual source code: dlregispetsc.c

      2: #include <petscdraw.h>
      3: #include <petscviewer.h>
      4: #include <petsc/private/viewerimpl.h>

      6: static PetscBool PetscSysPackageInitialized = PETSC_FALSE;

      8: /*@C
      9:   PetscSysFinalizePackage - This function destroys everything in the PETSc created internally in the system library portion of PETSc.
     10:   It is called from PetscFinalize().

     12:   Level: developer

     14: .seealso: PetscFinalize()
     15: @*/
     16: PetscErrorCode  PetscSysFinalizePackage(void)
     17: {
     18:   if (Petsc_Seq_keyval != MPI_KEYVAL_INVALID) {
     19:     MPI_Comm_free_keyval(&Petsc_Seq_keyval);
     20:   }
     21:   PetscSysPackageInitialized = PETSC_FALSE;
     22:   return 0;
     23: }

     25: /*@C
     26:   PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called
     27:   from PetscDLLibraryRegister_petsc() when using dynamic libraries, and on the call to PetscInitialize()
     28:   when using shared or static libraries.

     30:   Level: developer

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

     39:   if (PetscSysPackageInitialized) return 0;
     40:   PetscSysPackageInitialized = PETSC_TRUE;
     41:   /* Register Classes */
     42:   PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID);
     43:   PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID);

     45:   /* Register Events */
     46:   PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier);
     47:   PetscLogEventRegister("BuildTwoSided",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSided);
     48:   PetscLogEventRegister("BuildTwoSidedF",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSidedF);
     49:   /* Process Info */
     50:   {
     51:     PetscClassId  classids[1];

     53:     classids[0] = PETSC_SMALLEST_CLASSID;
     54:     PetscInfoProcessClass("sys", 1, classids);
     55:   }
     56:   /* Process summary exclusions */
     57:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
     58:   if (opt) {
     59:     PetscStrInList("null",logList,',',&pkg);
     60:     if (pkg) PetscLogEventExcludeClass(PETSC_SMALLEST_CLASSID);
     61:   }
     62:   PetscRegisterFinalize(PetscSysFinalizePackage);
     63:   return 0;
     64: }

     66: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

     68: #if defined(PETSC_USE_SINGLE_LIBRARY)
     69: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void);
     70: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void);
     71: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void);
     72: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void);
     73: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void);
     74: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void);
     75: #endif

     77: /*
     78:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

     80:   This one registers all the system level objects.

     82:  */
     83: #if defined(PETSC_USE_SINGLE_LIBRARY)
     84: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void)
     85: #else
     86: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void)
     87: #endif
     88: {
     89:   /*
     90:       If we got here then PETSc was properly loaded
     91:   */
     92:   PetscSysInitializePackage();
     93:   PetscDrawInitializePackage();
     94:   PetscViewerInitializePackage();
     95:   PetscRandomInitializePackage();

     97: #if defined(PETSC_USE_SINGLE_LIBRARY)
     98:   PetscDLLibraryRegister_petscvec();
     99:   PetscDLLibraryRegister_petscmat();
    100:   PetscDLLibraryRegister_petscdm();
    101:   PetscDLLibraryRegister_petscksp();
    102:   PetscDLLibraryRegister_petscsnes();
    103:   PetscDLLibraryRegister_petscts();
    104: #endif
    105:   return 0;
    106: }
    107: #endif  /* PETSC_HAVE_DYNAMIC_LIBRARIES */