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