1 2 #include <petscdraw.h> 3 #include <petscviewer.h> 4 #include <petsc/private/viewerimpl.h> 5 6 static PetscBool PetscSysPackageInitialized = PETSC_FALSE; 7 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(). 11 12 Level: developer 13 14 .seealso: PetscFinalize() 15 @*/ 16 PetscErrorCode PetscSysFinalizePackage(void) 17 { 18 PetscFunctionBegin; 19 if (Petsc_Seq_keyval != MPI_KEYVAL_INVALID) { 20 CHKERRMPI(MPI_Comm_free_keyval(&Petsc_Seq_keyval)); 21 } 22 PetscSysPackageInitialized = PETSC_FALSE; 23 PetscFunctionReturn(0); 24 } 25 26 /*@C 27 PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called 28 from PetscDLLibraryRegister_petsc() when using dynamic libraries, and on the call to PetscInitialize() 29 when using shared or static libraries. 30 31 Level: developer 32 33 .seealso: PetscInitialize() 34 @*/ 35 PetscErrorCode PetscSysInitializePackage(void) 36 { 37 char logList[256]; 38 PetscBool opt,pkg; 39 40 PetscFunctionBegin; 41 if (PetscSysPackageInitialized) PetscFunctionReturn(0); 42 PetscSysPackageInitialized = PETSC_TRUE; 43 /* Register Classes */ 44 CHKERRQ(PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID)); 45 CHKERRQ(PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID)); 46 47 /* Register Events */ 48 CHKERRQ(PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier)); 49 CHKERRQ(PetscLogEventRegister("BuildTwoSided",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSided)); 50 CHKERRQ(PetscLogEventRegister("BuildTwoSidedF",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSidedF)); 51 /* Process Info */ 52 { 53 PetscClassId classids[1]; 54 55 classids[0] = PETSC_SMALLEST_CLASSID; 56 CHKERRQ(PetscInfoProcessClass("sys", 1, classids)); 57 } 58 /* Process summary exclusions */ 59 CHKERRQ(PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt)); 60 if (opt) { 61 CHKERRQ(PetscStrInList("null",logList,',',&pkg)); 62 if (pkg) CHKERRQ(PetscLogEventExcludeClass(PETSC_SMALLEST_CLASSID)); 63 } 64 CHKERRQ(PetscRegisterFinalize(PetscSysFinalizePackage)); 65 PetscFunctionReturn(0); 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 CHKERRQ(PetscSysInitializePackage()); 96 CHKERRQ(PetscDrawInitializePackage()); 97 CHKERRQ(PetscViewerInitializePackage()); 98 CHKERRQ(PetscRandomInitializePackage()); 99 100 #if defined(PETSC_USE_SINGLE_LIBRARY) 101 CHKERRQ(PetscDLLibraryRegister_petscvec()); 102 CHKERRQ(PetscDLLibraryRegister_petscmat()); 103 CHKERRQ(PetscDLLibraryRegister_petscdm()); 104 CHKERRQ(PetscDLLibraryRegister_petscksp()); 105 CHKERRQ(PetscDLLibraryRegister_petscsnes()); 106 CHKERRQ(PetscDLLibraryRegister_petscts()); 107 #endif 108 PetscFunctionReturn(0); 109 } 110 #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */ 111