xref: /petsc/src/sys/classes/viewer/interface/dlregispetsc.c (revision 19caf8f3c08b1f0ca9f5469bde385c134aa76c82)
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   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 @*/
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 exclusions */
55   ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
56   if (opt) {
57     ierr = PetscStrInList("null",logList,',',&pkg);CHKERRQ(ierr);
58     if (pkg) {ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr);}
59   }
60   /* Process summary exclusions */
61   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
62   if (opt) {
63     ierr = PetscStrInList("null",logList,',',&pkg);CHKERRQ(ierr);
64     if (pkg) {ierr = PetscLogEventExcludeClass(PETSC_SMALLEST_CLASSID);CHKERRQ(ierr);}
65   }
66   ierr = PetscRegisterFinalize(PetscSysFinalizePackage);CHKERRQ(ierr);
67   PetscFunctionReturn(0);
68 }
69 
70 #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
71 
72 #if defined(PETSC_USE_SINGLE_LIBRARY)
73 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void);
74 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void);
75 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void);
76 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void);
77 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void);
78 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void);
79 #endif
80 
81 #if defined(PETSC_USE_SINGLE_LIBRARY)
82 #else
83 #endif
84 /*
85   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
86 
87   This one registers all the draw and PetscViewer objects.
88 
89  */
90 #if defined(PETSC_USE_SINGLE_LIBRARY)
91 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void)
92 #else
93 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void)
94 #endif
95 {
96   PetscErrorCode ierr;
97 
98   PetscFunctionBegin;
99   /*
100       If we got here then PETSc was properly loaded
101   */
102   ierr = PetscSysInitializePackage();CHKERRQ(ierr);
103   ierr = PetscDrawInitializePackage();CHKERRQ(ierr);
104   ierr = PetscViewerInitializePackage();CHKERRQ(ierr);
105   ierr = PetscRandomInitializePackage();CHKERRQ(ierr);
106 
107 #if defined(PETSC_USE_SINGLE_LIBRARY)
108   ierr = PetscDLLibraryRegister_petscvec();CHKERRQ(ierr);
109   ierr = PetscDLLibraryRegister_petscmat();CHKERRQ(ierr);
110   ierr = PetscDLLibraryRegister_petscdm();CHKERRQ(ierr);
111   ierr = PetscDLLibraryRegister_petscksp();CHKERRQ(ierr);
112   ierr = PetscDLLibraryRegister_petscsnes();CHKERRQ(ierr);
113   ierr = PetscDLLibraryRegister_petscts();CHKERRQ(ierr);
114 #endif
115   PetscFunctionReturn(0);
116 }
117 #endif  /* PETSC_HAVE_DYNAMIC_LIBRARIES */
118