xref: /petsc/src/sys/classes/viewer/interface/dlregispetsc.c (revision 9137bce663dafc076b984eb551047684322ddd3c)
1 
2 #include <petscdraw.h>
3 #include <petscviewer.h>
4 
5 extern PetscLogEvent PETSC_Barrier,PETSC_BuildTwoSided,PETSC_BuildTwoSidedF;
6 
7 static PetscBool PetscSysPackageInitialized = PETSC_FALSE;
8 /*@C
9   PetscSysFinalizePackage - This function destroys everything in the Petsc interface to Mathematica. It is
10   called from PetscFinalize().
11 
12   Level: developer
13 
14 .keywords: Petsc, destroy, package, mathematica
15 .seealso: PetscFinalize()
16 @*/
17 PetscErrorCode  PetscSysFinalizePackage(void)
18 {
19   PetscFunctionBegin;
20   PetscSysPackageInitialized = PETSC_FALSE;
21   PetscFunctionReturn(0);
22 }
23 
24 /*@C
25   PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called
26   from PetscDLLibraryRegister() when using dynamic libraries, and on the call to PetscInitialize()
27   when using static libraries.
28 
29   Level: developer
30 
31 .keywords: Petsc, initialize, package
32 .seealso: PetscInitialize()
33 @*/
34 PetscErrorCode  PetscSysInitializePackage(void)
35 {
36   char           logList[256];
37   char           *className;
38   PetscBool      opt;
39   PetscErrorCode ierr;
40 
41   PetscFunctionBegin;
42   if (PetscSysPackageInitialized) PetscFunctionReturn(0);
43   PetscSysPackageInitialized = PETSC_TRUE;
44   /* Register Classes */
45   ierr = PetscClassIdRegister("Object",&PETSC_OBJECT_CLASSID);CHKERRQ(ierr);
46   ierr = PetscClassIdRegister("Container",&PETSC_CONTAINER_CLASSID);CHKERRQ(ierr);
47 
48   /* Register Events */
49   ierr = PetscLogEventRegister("PetscBarrier", PETSC_SMALLEST_CLASSID,&PETSC_Barrier);CHKERRQ(ierr);
50   ierr = PetscLogEventRegister("BuildTwoSided",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSided);CHKERRQ(ierr);
51   ierr = PetscLogEventRegister("BuildTwoSidedF",PETSC_SMALLEST_CLASSID,&PETSC_BuildTwoSidedF);CHKERRQ(ierr);
52   /* Process info exclusions */
53   ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
54   if (opt) {
55     ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr);
56     if (className) {
57       ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr);
58     }
59   }
60   /* Process summary exclusions */
61   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
62   if (opt) {
63     ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr);
64     if (className) {
65       ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr);
66     }
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