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) MPI_Comm_free_keyval(&Petsc_Seq_keyval);
 19:   PetscSysPackageInitialized = PETSC_FALSE;
 20:   return 0;
 21: }

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

 28:   Level: developer

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

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

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

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

 64: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)

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

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

 78:   This one registers all the system level objects.

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

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