xref: /petsc/src/sys/classes/viewer/interface/dlregispetsc.c (revision 075987266ca0d0e8d09d008387b2c5b96849a557)
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 #undef __FUNCT__
9 #define __FUNCT__ "PetscSysFinalizePackage"
10 /*@C
11   PetscSysFinalizePackage - This function destroys everything in the Petsc interface to Mathematica. It is
12   called from PetscFinalize().
13 
14   Level: developer
15 
16 .keywords: Petsc, destroy, package, mathematica
17 .seealso: PetscFinalize()
18 @*/
19 PetscErrorCode  PetscSysFinalizePackage(void)
20 {
21   PetscFunctionBegin;
22   PetscSysPackageInitialized = PETSC_FALSE;
23   PetscFunctionReturn(0);
24 }
25 
26 #undef __FUNCT__
27 #define __FUNCT__ "PetscSysInitializePackage"
28 /*@C
29   PetscSysInitializePackage - This function initializes everything in the main Petsc package. It is called
30   from PetscDLLibraryRegister() when using dynamic libraries, and on the call to PetscInitialize()
31   when using static libraries.
32 
33   Level: developer
34 
35 .keywords: Petsc, initialize, package
36 .seealso: PetscInitialize()
37 @*/
38 PetscErrorCode  PetscSysInitializePackage(void)
39 {
40   char           logList[256];
41   char           *className;
42   PetscBool      opt;
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, 256, &opt);CHKERRQ(ierr);
58   if (opt) {
59     ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr);
60     if (className) {
61       ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr);
62     }
63   }
64   /* Process summary exclusions */
65   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
66   if (opt) {
67     ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr);
68     if (className) {
69       ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr);
70     }
71   }
72   ierr = PetscRegisterFinalize(PetscSysFinalizePackage);CHKERRQ(ierr);
73   PetscFunctionReturn(0);
74 }
75 
76 #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
77 
78 #if defined(PETSC_USE_SINGLE_LIBRARY)
79 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void);
80 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void);
81 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void);
82 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void);
83 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void);
84 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void);
85 #endif
86 
87 #undef __FUNCT__
88 #if defined(PETSC_USE_SINGLE_LIBRARY)
89 #define __FUNCT__ "PetscDLLibraryRegister_petsc"
90 #else
91 #define __FUNCT__ "PetscDLLibraryRegister_petscsys"
92 #endif
93 /*
94   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
95 
96   This one registers all the draw and PetscViewer objects.
97 
98  */
99 #if defined(PETSC_USE_SINGLE_LIBRARY)
100 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void)
101 #else
102 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void)
103 #endif
104 {
105   PetscErrorCode ierr;
106 
107   PetscFunctionBegin;
108   /*
109       If we got here then PETSc was properly loaded
110   */
111   ierr = PetscSysInitializePackage();CHKERRQ(ierr);
112   ierr = PetscDrawInitializePackage();CHKERRQ(ierr);
113   ierr = PetscViewerInitializePackage();CHKERRQ(ierr);
114   ierr = PetscRandomInitializePackage();CHKERRQ(ierr);
115 
116 #if defined(PETSC_USE_SINGLE_LIBRARY)
117   ierr = PetscDLLibraryRegister_petscvec();CHKERRQ(ierr);
118   ierr = PetscDLLibraryRegister_petscmat();CHKERRQ(ierr);
119   ierr = PetscDLLibraryRegister_petscdm();CHKERRQ(ierr);
120   ierr = PetscDLLibraryRegister_petscksp();CHKERRQ(ierr);
121   ierr = PetscDLLibraryRegister_petscsnes();CHKERRQ(ierr);
122   ierr = PetscDLLibraryRegister_petscts();CHKERRQ(ierr);
123 #endif
124   PetscFunctionReturn(0);
125 }
126 #endif  /* PETSC_HAVE_DYNAMIC_LIBRARIES */
127