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