1 2 #include <petscdraw.h> 3 #include <petscviewer.h> 4 5 extern PetscLogEvent PETSC_Barrier; 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 /* Process info exclusions */ 55 ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 56 if (opt) { 57 ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 58 if (className) { 59 ierr = PetscInfoDeactivateClass(0);CHKERRQ(ierr); 60 } 61 } 62 /* Process summary exclusions */ 63 ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 64 if (opt) { 65 ierr = PetscStrstr(logList, "null", &className);CHKERRQ(ierr); 66 if (className) { 67 ierr = PetscLogEventDeactivateClass(0);CHKERRQ(ierr); 68 } 69 } 70 ierr = PetscRegisterFinalize(PetscSysFinalizePackage);CHKERRQ(ierr); 71 PetscFunctionReturn(0); 72 } 73 74 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 75 76 #if defined(PETSC_USE_SINGLE_LIBRARY) 77 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscvec(void); 78 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscmat(void); 79 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void); 80 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscksp(void); 81 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void); 82 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); 83 #endif 84 85 #undef __FUNCT__ 86 #if defined(PETSC_USE_SINGLE_LIBRARY) 87 #define __FUNCT__ "PetscDLLibraryRegister_petsc" 88 #else 89 #define __FUNCT__ "PetscDLLibraryRegister_petscsys" 90 #endif 91 /* 92 PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 93 94 This one registers all the draw and PetscViewer objects. 95 96 */ 97 #if defined(PETSC_USE_SINGLE_LIBRARY) 98 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsc(void) 99 #else 100 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsys(void) 101 #endif 102 { 103 PetscErrorCode ierr; 104 105 PetscFunctionBegin; 106 /* 107 If we got here then PETSc was properly loaded 108 */ 109 ierr = PetscSysInitializePackage();CHKERRQ(ierr); 110 ierr = PetscDrawInitializePackage();CHKERRQ(ierr); 111 ierr = PetscViewerInitializePackage();CHKERRQ(ierr); 112 ierr = PetscRandomInitializePackage();CHKERRQ(ierr); 113 114 #if defined(PETSC_USE_SINGLE_LIBRARY) 115 ierr = PetscDLLibraryRegister_petscvec();CHKERRQ(ierr); 116 ierr = PetscDLLibraryRegister_petscmat();CHKERRQ(ierr); 117 ierr = PetscDLLibraryRegister_petscdm();CHKERRQ(ierr); 118 ierr = PetscDLLibraryRegister_petscksp();CHKERRQ(ierr); 119 ierr = PetscDLLibraryRegister_petscsnes();CHKERRQ(ierr); 120 ierr = PetscDLLibraryRegister_petscts();CHKERRQ(ierr); 121 #endif 122 PetscFunctionReturn(0); 123 } 124 #endif 125 126 127