Actual source code: dlregisdm.c

petsc-3.3-p7 2013-05-11
  2: #include <../src/dm/ao/aoimpl.h>
  3: #include <petsc-private/daimpl.h>
  4: #ifdef PETSC_HAVE_SIEVE
  5: #include <petsc-private/meshimpl.h>
  6: #endif

  8: static PetscBool  AOPackageInitialized = PETSC_FALSE;

 12: /*@C
 13:   AOFinalizePackage - This function finalizes everything in the AO package. It is called
 14:   from PetscFinalize().

 16:   Level: developer

 18: .keywords: AO, initialize, package
 19: .seealso: PetscInitialize()
 20: @*/
 21: PetscErrorCode  AOFinalizePackage(void)
 22: {
 24:   AOPackageInitialized = PETSC_FALSE;
 25:   return(0);
 26: }

 30: /*@C
 31:   AOInitializePackage - This function initializes everything in the AO package. It is called
 32:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate().

 34:   Input Parameter:
 35:   path - The dynamic library path, or PETSC_NULL

 37:   Level: developer

 39: .keywords: AO, initialize, package
 40: .seealso: PetscInitialize()
 41: @*/
 42: PetscErrorCode  AOInitializePackage(const char path[])
 43: {
 44:   char              logList[256];
 45:   char              *className;
 46:   PetscBool         opt;
 47:   PetscErrorCode    ierr;

 50:   if (AOPackageInitialized) return(0);
 51:   AOPackageInitialized = PETSC_TRUE;
 52:   /* Register Classes */
 53:   PetscClassIdRegister("Application Order",&AO_CLASSID);
 54:   /* Register Constructors */
 55:   AORegisterAll(path);
 56:   /* Register Events */
 57:   PetscLogEventRegister("AOPetscToApplication", AO_CLASSID,&AO_PetscToApplication);
 58:   PetscLogEventRegister("AOApplicationToPetsc", AO_CLASSID,&AO_ApplicationToPetsc);
 59:   /* Process info exclusions */
 60:   PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
 61:   if (opt) {
 62:     PetscStrstr(logList, "ao", &className);
 63:     if (className) {
 64:       PetscInfoDeactivateClass(AO_CLASSID);
 65:     }
 66:   }
 67:   /* Process summary exclusions */
 68:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
 69:   if (opt) {
 70:     PetscStrstr(logList, "ao", &className);
 71:     if (className) {
 72:       PetscLogEventDeactivateClass(AO_CLASSID);
 73:     }
 74:   }
 75:   PetscRegisterFinalize(AOFinalizePackage);
 76:   return(0);
 77: }

 79: static PetscBool  DMPackageInitialized = PETSC_FALSE;
 82: /*@C
 83:   DMFinalizePackage - This function finalizes everything in the DM package. It is called
 84:   from PetscFinalize().

 86:   Level: developer

 88: .keywords: AO, initialize, package
 89: .seealso: PetscInitialize()
 90: @*/
 91: PetscErrorCode  DMFinalizePackage(void)
 92: {
 93: #ifdef PETSC_HAVE_SIEVE
 95: #endif

 98:   DMPackageInitialized = PETSC_FALSE;
 99:   DMList               = PETSC_NULL;
100:   DMRegisterAllCalled  = PETSC_FALSE;
101: #ifdef PETSC_HAVE_SIEVE
102:   DMMeshFinalize();
103: #endif
104:   return(0);
105: }

107: #if defined(PETSC_HAVE_HYPRE)
108: EXTERN_C_BEGIN
109: extern PetscErrorCode  MatCreate_HYPREStruct(Mat);
110: EXTERN_C_END
111: #endif

115: /*@C
116:   DMInitializePackage - This function initializes everything in the DM package. It is called
117:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate()
118:   or DMDACreate() when using static libraries.

120:   Input Parameter:
121:   path - The dynamic library path, or PETSC_NULL

123:   Level: developer

125: .keywords: AO, initialize, package
126: .seealso: PetscInitialize()
127: @*/
128: PetscErrorCode  DMInitializePackage(const char path[])
129: {
130:   char              logList[256];
131:   char              *className;
132:   PetscBool         opt;
133:   PetscErrorCode    ierr;

136:   if (DMPackageInitialized) return(0);
137:   DMPackageInitialized = PETSC_TRUE;

139:   /* Register Classes */
140:   PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);
141: #ifdef PETSC_HAVE_SIEVE
142:   PetscClassIdRegister("SectionReal",&SECTIONREAL_CLASSID);
143:   PetscClassIdRegister("SectionInt",&SECTIONINT_CLASSID);
144: #endif

146: #if defined(PETSC_HAVE_HYPRE)
147:   MatRegisterDynamic(MATHYPRESTRUCT,    path,"MatCreate_HYPREStruct", MatCreate_HYPREStruct);
148: #endif

150:   /* Register Constructors */
151:   DMRegisterAll(path);
152:   /* Register Events */
153:   PetscLogEventRegister("DMConvert",              DM_CLASSID,&DM_Convert);
154:   PetscLogEventRegister("DMGlobalToLocal",        DM_CLASSID,&DM_GlobalToLocal);
155:   PetscLogEventRegister("DMLocalToGlobal",        DM_CLASSID,&DM_LocalToGlobal);

157:   PetscLogEventRegister("DMDALocalADFunc",        DM_CLASSID,&DMDA_LocalADFunction);

159: #ifdef PETSC_HAVE_SIEVE
160:   PetscLogEventRegister("DMMeshView",             DM_CLASSID,&DMMesh_View);
161:   PetscLogEventRegister("DMMeshGetGlobalScatter", DM_CLASSID,&DMMesh_GetGlobalScatter);
162:   PetscLogEventRegister("DMMeshRestrictVector",   DM_CLASSID,&DMMesh_restrictVector);
163:   PetscLogEventRegister("DMMeshAssembleVector",   DM_CLASSID,&DMMesh_assembleVector);
164:   PetscLogEventRegister("DMMeshAssemVecComplete", DM_CLASSID,&DMMesh_assembleVectorComplete);
165:   PetscLogEventRegister("DMMeshAssembleMatrix",   DM_CLASSID,&DMMesh_assembleMatrix);
166:   PetscLogEventRegister("DMMeshUpdateOperator",   DM_CLASSID,&DMMesh_updateOperator);
167:   PetscLogEventRegister("SectionRealView",        SECTIONREAL_CLASSID,&SectionReal_View);
168:   PetscLogEventRegister("SectionIntView",         SECTIONINT_CLASSID,&SectionInt_View);
169: #endif
170:   /* Process info exclusions */
171:   PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);
172:   if (opt) {
173:     PetscStrstr(logList, "da", &className);
174:     if (className) {
175:       PetscInfoDeactivateClass(DM_CLASSID);
176:     }
177: #ifdef PETSC_HAVE_SIEVE
178:     PetscStrstr(logList, "sectionreal", &className);
179:     if (className) {
180:       PetscInfoDeactivateClass(SECTIONREAL_CLASSID);
181:     }
182:     PetscStrstr(logList, "sectionint", &className);
183:     if (className) {
184:       PetscInfoDeactivateClass(SECTIONINT_CLASSID);
185:     }
186: #endif
187:   }
188:   /* Process summary exclusions */
189:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
190:   if (opt) {
191:     PetscStrstr(logList, "da", &className);
192:     if (className) {
193:       PetscLogEventDeactivateClass(DM_CLASSID);
194:     }
195: #ifdef PETSC_HAVE_SIEVE
196:     PetscStrstr(logList, "sectionreal", &className);
197:     if (className) {
198:       PetscLogEventDeactivateClass(SECTIONREAL_CLASSID);
199:     }
200:     PetscStrstr(logList, "sectionint", &className);
201:     if (className) {
202:       PetscLogEventDeactivateClass(SECTIONINT_CLASSID);
203:     }
204: #endif
205:   }
206:   PetscRegisterFinalize(DMFinalizePackage);
207:   return(0);
208: }



212: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
213: EXTERN_C_BEGIN
216: /*
217:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

219:   This one registers all the mesh generators and partitioners that are in
220:   the basic DM library.

222:   Input Parameter:
223:   path - library path
224: */
225: PetscErrorCode  PetscDLLibraryRegister_petscdm(const char path[])
226: {


231:   AOInitializePackage(path);
232:   DMInitializePackage(path);
233:   return(0);
234: }
235: EXTERN_C_END

237: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */