1 #include <petscdraw.h> 2 #include <petscviewer.h> 3 #include <petsc/private/viewerimpl.h> 4 5 static PetscBool PetscSysPackageInitialized = PETSC_FALSE; 6 7 /*@C 8 PetscSysFinalizePackage - This function destroys everything in the system library portion of PETSc. 9 It is called from `PetscFinalize()`. 10 11 Level: developer 12 13 .seealso: `PetscSysInitializePackage()`, `PetscFinalize()` 14 @*/ 15 PetscErrorCode PetscSysFinalizePackage(void) 16 { 17 PetscFunctionBegin; 18 if (Petsc_Seq_keyval != MPI_KEYVAL_INVALID) PetscCallMPI(MPI_Comm_free_keyval(&Petsc_Seq_keyval)); 19 PetscSysPackageInitialized = PETSC_FALSE; 20 PetscFunctionReturn(PETSC_SUCCESS); 21 } 22 23 /*@C 24 PetscSysInitializePackage - This function initializes everything in the system library portion of PETSc. It is called 25 from `PetscDLLibraryRegister_petsc()` when using dynamic libraries, and in the call to `PetscInitialize()` 26 when using shared or static libraries. 27 28 Level: developer 29 30 Note: 31 This function never needs to be called by PETSc users. 32 33 .seealso: `PetscSysFinalizePackage()`, `PetscInitialize()` 34 @*/ 35 PetscErrorCode PetscSysInitializePackage(void) 36 { 37 char logList[256]; 38 PetscBool opt, pkg; 39 40 PetscFunctionBegin; 41 if (PetscSysPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS); 42 PetscSysPackageInitialized = PETSC_TRUE; 43 /* Register Classes */ 44 PetscCall(PetscClassIdRegister("Object", &PETSC_OBJECT_CLASSID)); 45 PetscCall(PetscClassIdRegister("Container", &PETSC_CONTAINER_CLASSID)); 46 47 /* Register Events */ 48 PetscCall(PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID, &PETSC_Barrier)); 49 PetscCall(PetscLogEventRegister("BuildTwoSided", PETSC_SMALLEST_CLASSID, &PETSC_BuildTwoSided)); 50 PetscCall(PetscLogEventRegister("BuildTwoSidedF", PETSC_SMALLEST_CLASSID, &PETSC_BuildTwoSidedF)); 51 /* Process Info */ 52 { 53 PetscClassId classids[1]; 54 55 classids[0] = PETSC_SMALLEST_CLASSID; 56 PetscCall(PetscInfoProcessClass("sys", 1, classids)); 57 } 58 /* Process summary exclusions */ 59 PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt)); 60 if (opt) { 61 PetscCall(PetscStrInList("null", logList, ',', &pkg)); 62 if (pkg) PetscCall(PetscLogEventExcludeClass(PETSC_SMALLEST_CLASSID)); 63 } 64 PetscCall(PetscRegisterFinalize(PetscSysFinalizePackage)); 65 PetscFunctionReturn(PETSC_SUCCESS); 66 } 67 68 #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES) 69 70 #if defined(PETSC_USE_SINGLE_LIBRARY) 71 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void); 72 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void); 73 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void); 74 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void); 75 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void); 76 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); 77 #endif 78 79 /* 80 PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 81 82 This one registers all the system level objects. 83 84 */ 85 #if defined(PETSC_USE_SINGLE_LIBRARY) 86 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void) 87 #else 88 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void) 89 #endif 90 { 91 PetscFunctionBegin; 92 /* 93 If we got here then PETSc was properly loaded 94 */ 95 PetscCall(PetscSysInitializePackage()); 96 PetscCall(PetscDrawInitializePackage()); 97 PetscCall(PetscViewerInitializePackage()); 98 PetscCall(PetscRandomInitializePackage()); 99 100 #if defined(PETSC_USE_SINGLE_LIBRARY) 101 PetscCall(PetscDLLibraryRegister_petscvec()); 102 PetscCall(PetscDLLibraryRegister_petscmat()); 103 PetscCall(PetscDLLibraryRegister_petscdm()); 104 PetscCall(PetscDLLibraryRegister_petscksp()); 105 PetscCall(PetscDLLibraryRegister_petscsnes()); 106 PetscCall(PetscDLLibraryRegister_petscts()); 107 #endif 108 PetscFunctionReturn(PETSC_SUCCESS); 109 } 110 #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ 111