1 2 #include <petsc-private/dmdaimpl.h> 3 #include <petsc-private/dmpleximpl.h> 4 #if defined(PETSC_HAVE_SIEVE) 5 #include <petsc-private/meshimpl.h> 6 #endif 7 8 static PetscBool DMPackageInitialized = PETSC_FALSE; 9 #undef __FUNCT__ 10 #define __FUNCT__ "DMFinalizePackage" 11 /*@C 12 DMFinalizePackage - This function finalizes everything in the DM package. It is called 13 from PetscFinalize(). 14 15 Level: developer 16 17 .keywords: AO, initialize, package 18 .seealso: PetscInitialize() 19 @*/ 20 PetscErrorCode DMFinalizePackage(void) 21 { 22 #if defined(PETSC_HAVE_SIEVE) 23 PetscErrorCode ierr; 24 #endif 25 26 PetscFunctionBegin; 27 DMPackageInitialized = PETSC_FALSE; 28 DMList = NULL; 29 DMRegisterAllCalled = PETSC_FALSE; 30 #if defined(PETSC_HAVE_SIEVE) 31 ierr = DMMeshFinalize();CHKERRQ(ierr); 32 #endif 33 PetscFunctionReturn(0); 34 } 35 36 #if defined(PETSC_HAVE_HYPRE) 37 PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat); 38 #endif 39 40 #undef __FUNCT__ 41 #define __FUNCT__ "DMInitializePackage" 42 /*@C 43 DMInitializePackage - This function initializes everything in the DM package. It is called 44 from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate() 45 or DMDACreate() when using static libraries. 46 47 Input Parameter: 48 path - The dynamic library path, or NULL 49 50 Level: developer 51 52 .keywords: AO, initialize, package 53 .seealso: PetscInitialize() 54 @*/ 55 PetscErrorCode DMInitializePackage(const char path[]) 56 { 57 char logList[256]; 58 char *className; 59 PetscBool opt; 60 PetscErrorCode ierr; 61 62 PetscFunctionBegin; 63 if (DMPackageInitialized) PetscFunctionReturn(0); 64 DMPackageInitialized = PETSC_TRUE; 65 66 /* Register Classes */ 67 ierr = PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);CHKERRQ(ierr); 68 #if defined(PETSC_HAVE_SIEVE) 69 ierr = PetscClassIdRegister("SectionReal",&SECTIONREAL_CLASSID);CHKERRQ(ierr); 70 ierr = PetscClassIdRegister("SectionInt",&SECTIONINT_CLASSID);CHKERRQ(ierr); 71 #endif 72 73 #if defined(PETSC_HAVE_HYPRE) 74 ierr = MatRegisterDynamic(MATHYPRESTRUCT, path,"MatCreate_HYPREStruct", MatCreate_HYPREStruct);CHKERRQ(ierr); 75 #endif 76 77 /* Register Constructors */ 78 ierr = DMRegisterAll(path);CHKERRQ(ierr); 79 /* Register Events */ 80 ierr = PetscLogEventRegister("DMConvert", DM_CLASSID,&DM_Convert);CHKERRQ(ierr); 81 ierr = PetscLogEventRegister("DMGlobalToLocal", DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr); 82 ierr = PetscLogEventRegister("DMLocalToGlobal", DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr); 83 84 ierr = PetscLogEventRegister("DMDALocalADFunc", DM_CLASSID,&DMDA_LocalADFunction);CHKERRQ(ierr); 85 86 ierr = PetscLogEventRegister("DMPlexDistribute", DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr); 87 ierr = PetscLogEventRegister("DMPlexStratify", DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr); 88 #if defined(PETSC_HAVE_SIEVE) 89 ierr = PetscLogEventRegister("DMMeshView", DM_CLASSID,&DMMesh_View);CHKERRQ(ierr); 90 ierr = PetscLogEventRegister("DMMeshGetGlobalScatter", DM_CLASSID,&DMMesh_GetGlobalScatter);CHKERRQ(ierr); 91 ierr = PetscLogEventRegister("DMMeshRestrictVector", DM_CLASSID,&DMMesh_restrictVector);CHKERRQ(ierr); 92 ierr = PetscLogEventRegister("DMMeshAssembleVector", DM_CLASSID,&DMMesh_assembleVector);CHKERRQ(ierr); 93 ierr = PetscLogEventRegister("DMMeshAssemVecComplete", DM_CLASSID,&DMMesh_assembleVectorComplete);CHKERRQ(ierr); 94 ierr = PetscLogEventRegister("DMMeshAssembleMatrix", DM_CLASSID,&DMMesh_assembleMatrix);CHKERRQ(ierr); 95 ierr = PetscLogEventRegister("DMMeshUpdateOperator", DM_CLASSID,&DMMesh_updateOperator);CHKERRQ(ierr); 96 ierr = PetscLogEventRegister("SectionRealView", SECTIONREAL_CLASSID,&SectionReal_View);CHKERRQ(ierr); 97 ierr = PetscLogEventRegister("SectionIntView", SECTIONINT_CLASSID,&SectionInt_View);CHKERRQ(ierr); 98 #endif 99 /* Process info exclusions */ 100 ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 101 if (opt) { 102 ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 103 if (className) { 104 ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 105 } 106 #if defined(PETSC_HAVE_SIEVE) 107 ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 108 if (className) { 109 ierr = PetscInfoDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 110 } 111 ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 112 if (className) { 113 ierr = PetscInfoDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 114 } 115 #endif 116 } 117 /* Process summary exclusions */ 118 ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 119 if (opt) { 120 ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr); 121 if (className) { 122 ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr); 123 } 124 #if defined(PETSC_HAVE_SIEVE) 125 ierr = PetscStrstr(logList, "sectionreal", &className);CHKERRQ(ierr); 126 if (className) { 127 ierr = PetscLogEventDeactivateClass(SECTIONREAL_CLASSID);CHKERRQ(ierr); 128 } 129 ierr = PetscStrstr(logList, "sectionint", &className);CHKERRQ(ierr); 130 if (className) { 131 ierr = PetscLogEventDeactivateClass(SECTIONINT_CLASSID);CHKERRQ(ierr); 132 } 133 #endif 134 } 135 ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr); 136 PetscFunctionReturn(0); 137 } 138 139 140 141 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 142 #undef __FUNCT__ 143 #define __FUNCT__ "PetscDLLibraryRegister_petscdm" 144 /* 145 PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 146 147 This one registers all the mesh generators and partitioners that are in 148 the basic DM library. 149 150 Input Parameter: 151 path - library path 152 */ 153 PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(const char path[]) 154 { 155 PetscErrorCode ierr; 156 157 PetscFunctionBegin; 158 ierr = AOInitializePackage(path);CHKERRQ(ierr); 159 ierr = DMInitializePackage(path);CHKERRQ(ierr); 160 PetscFunctionReturn(0); 161 } 162 163 #endif /* PETSC_USE_DYNAMIC_LIBRARIES */ 164