Actual source code: dlregisdmdm.c


  2: #include <petscao.h>
  3: #include <petsc/private/dmlabelimpl.h>
  4: #include <petsc/private/dmfieldimpl.h>
  5: #include <petsc/private/dmpleximpl.h>
  6: #include <petsc/private/dmplextransformimpl.h>
  7: #include <petsc/private/petscdsimpl.h>
  8: #include <petsc/private/petscfeimpl.h>
  9: #include <petsc/private/petscfvimpl.h>
 10: #include <petsc/private/dmswarmimpl.h>
 11: #include <petsc/private/dmnetworkimpl.h>

 13: static PetscBool DMPackageInitialized = PETSC_FALSE;
 14: /*@C
 15:   DMFinalizePackage - This function finalizes everything in the DM package. It is called
 16:   from PetscFinalize().

 18:   Level: developer

 20: .seealso: `PetscInitialize()`
 21: @*/
 22: PetscErrorCode DMFinalizePackage(void)
 23: {
 24:   PetscFunctionListDestroy(&DMList);
 25:   DMPackageInitialized = PETSC_FALSE;
 26:   DMRegisterAllCalled  = PETSC_FALSE;
 27:   return 0;
 28: }

 30: #if defined(PETSC_HAVE_HYPRE)
 31: PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat);
 32: PETSC_EXTERN PetscErrorCode MatCreate_HYPRESStruct(Mat);
 33: #endif

 35: /*@C
 36:   DMInitializePackage - This function initializes everything in the DM package. It is called
 37:   from PetscDLLibraryRegister_petscdm() when using dynamic libraries, and on the first call to AOCreate()
 38:   or DMDACreate() when using shared or static libraries.

 40:   Level: developer

 42: .seealso: `PetscInitialize()`
 43: @*/
 44: PetscErrorCode DMInitializePackage(void)
 45: {
 46:   char      logList[256];
 47:   PetscBool opt, pkg;

 49:   if (DMPackageInitialized) return 0;
 50:   DMPackageInitialized = PETSC_TRUE;

 52:   /* Register Classes */
 53:   PetscClassIdRegister("Distributed Mesh", &DM_CLASSID);
 54:   PetscClassIdRegister("DM Label", &DMLABEL_CLASSID);
 55:   PetscClassIdRegister("Quadrature", &PETSCQUADRATURE_CLASSID);
 56:   PetscClassIdRegister("Mesh Transform", &DMPLEXTRANSFORM_CLASSID);

 58: #if defined(PETSC_HAVE_HYPRE)
 59:   MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);
 60:   MatRegister(MATHYPRESSTRUCT, MatCreate_HYPRESStruct);
 61: #endif
 62:   PetscSectionSymRegister(PETSCSECTIONSYMLABEL, PetscSectionSymCreate_Label);

 64:   /* Register Constructors */
 65:   DMRegisterAll();
 66:   /* Register Events */
 67:   PetscLogEventRegister("DMConvert", DM_CLASSID, &DM_Convert);
 68:   PetscLogEventRegister("DMGlobalToLocal", DM_CLASSID, &DM_GlobalToLocal);
 69:   PetscLogEventRegister("DMLocalToGlobal", DM_CLASSID, &DM_LocalToGlobal);
 70:   PetscLogEventRegister("DMLocatePoints", DM_CLASSID, &DM_LocatePoints);
 71:   PetscLogEventRegister("DMCoarsen", DM_CLASSID, &DM_Coarsen);
 72:   PetscLogEventRegister("DMRefine", DM_CLASSID, &DM_Refine);
 73:   PetscLogEventRegister("DMCreateInterp", DM_CLASSID, &DM_CreateInterpolation);
 74:   PetscLogEventRegister("DMCreateRestrict", DM_CLASSID, &DM_CreateRestriction);
 75:   PetscLogEventRegister("DMCreateInject", DM_CLASSID, &DM_CreateInjection);
 76:   PetscLogEventRegister("DMCreateMat", DM_CLASSID, &DM_CreateMatrix);
 77:   PetscLogEventRegister("DMCreateMassMat", DM_CLASSID, &DM_CreateMassMatrix);
 78:   PetscLogEventRegister("DMLoad", DM_CLASSID, &DM_Load);
 79:   PetscLogEventRegister("DMAdaptInterp", DM_CLASSID, &DM_AdaptInterpolator);

 81:   PetscLogEventRegister("DMPlexBuFrCeLi", DM_CLASSID, &DMPLEX_BuildFromCellList);
 82:   PetscLogEventRegister("DMPlexBuCoFrCeLi", DM_CLASSID, &DMPLEX_BuildCoordinatesFromCellList);
 83:   PetscLogEventRegister("DMPlexCreateGmsh", DM_CLASSID, &DMPLEX_CreateGmsh);
 84:   PetscLogEventRegister("DMPlexCrFromFile", DM_CLASSID, &DMPLEX_CreateFromFile);
 85:   PetscLogEventRegister("Mesh Partition", DM_CLASSID, &DMPLEX_Partition);
 86:   PetscLogEventRegister("Mesh Migration", DM_CLASSID, &DMPLEX_Migrate);
 87:   PetscLogEventRegister("DMPlexPartSelf", DM_CLASSID, &DMPLEX_PartSelf);
 88:   PetscLogEventRegister("DMPlexPartLblInv", DM_CLASSID, &DMPLEX_PartLabelInvert);
 89:   PetscLogEventRegister("DMPlexPartLblSF", DM_CLASSID, &DMPLEX_PartLabelCreateSF);
 90:   PetscLogEventRegister("DMPlexPartStrtSF", DM_CLASSID, &DMPLEX_PartStratSF);
 91:   PetscLogEventRegister("DMPlexPointSF", DM_CLASSID, &DMPLEX_CreatePointSF);
 92:   PetscLogEventRegister("DMPlexInterp", DM_CLASSID, &DMPLEX_Interpolate);
 93:   PetscLogEventRegister("DMPlexDistribute", DM_CLASSID, &DMPLEX_Distribute);
 94:   PetscLogEventRegister("DMPlexDistCones", DM_CLASSID, &DMPLEX_DistributeCones);
 95:   PetscLogEventRegister("DMPlexDistLabels", DM_CLASSID, &DMPLEX_DistributeLabels);
 96:   PetscLogEventRegister("DMPlexDistSF", DM_CLASSID, &DMPLEX_DistributeSF);
 97:   PetscLogEventRegister("DMPlexDistOvrlp", DM_CLASSID, &DMPLEX_DistributeOverlap);
 98:   PetscLogEventRegister("DMPlexDistField", DM_CLASSID, &DMPLEX_DistributeField);
 99:   PetscLogEventRegister("DMPlexDistData", DM_CLASSID, &DMPLEX_DistributeData);
100:   PetscLogEventRegister("DMPlexInterpSF", DM_CLASSID, &DMPLEX_InterpolateSF);
101:   PetscLogEventRegister("DMPlexGToNBegin", DM_CLASSID, &DMPLEX_GlobalToNaturalBegin);
102:   PetscLogEventRegister("DMPlexGToNEnd", DM_CLASSID, &DMPLEX_GlobalToNaturalEnd);
103:   PetscLogEventRegister("DMPlexNToGBegin", DM_CLASSID, &DMPLEX_NaturalToGlobalBegin);
104:   PetscLogEventRegister("DMPlexNToGEnd", DM_CLASSID, &DMPLEX_NaturalToGlobalEnd);
105:   PetscLogEventRegister("DMPlexStratify", DM_CLASSID, &DMPLEX_Stratify);
106:   PetscLogEventRegister("DMPlexSymmetrize", DM_CLASSID, &DMPLEX_Symmetrize);
107:   PetscLogEventRegister("DMPlexPrealloc", DM_CLASSID, &DMPLEX_Preallocate);
108:   PetscLogEventRegister("DMPlexResidualFE", DM_CLASSID, &DMPLEX_ResidualFEM);
109:   PetscLogEventRegister("DMPlexJacobianFE", DM_CLASSID, &DMPLEX_JacobianFEM);
110:   PetscLogEventRegister("DMPlexInterpFE", DM_CLASSID, &DMPLEX_InterpolatorFEM);
111:   PetscLogEventRegister("DMPlexInjectorFE", DM_CLASSID, &DMPLEX_InjectorFEM);
112:   PetscLogEventRegister("DMPlexIntegralFEM", DM_CLASSID, &DMPLEX_IntegralFEM);
113:   PetscLogEventRegister("DMPlexRebalance", DM_CLASSID, &DMPLEX_RebalanceSharedPoints);
114:   PetscLogEventRegister("DMPlexLocatePoints", DM_CLASSID, &DMPLEX_LocatePoints);
115:   PetscLogEventRegister("DMPlexTopologyView", DM_CLASSID, &DMPLEX_TopologyView);
116:   PetscLogEventRegister("DMPlexLabelsView", DM_CLASSID, &DMPLEX_LabelsView);
117:   PetscLogEventRegister("DMPlexCoordinatesView", DM_CLASSID, &DMPLEX_CoordinatesView);
118:   PetscLogEventRegister("DMPlexSectionView", DM_CLASSID, &DMPLEX_SectionView);
119:   PetscLogEventRegister("DMPlexGlobalVectorView", DM_CLASSID, &DMPLEX_GlobalVectorView);
120:   PetscLogEventRegister("DMPlexLocalVectorView", DM_CLASSID, &DMPLEX_LocalVectorView);
121:   PetscLogEventRegister("DMPlexTopologyLoad", DM_CLASSID, &DMPLEX_TopologyLoad);
122:   PetscLogEventRegister("DMPlexLabelsLoad", DM_CLASSID, &DMPLEX_LabelsLoad);
123:   PetscLogEventRegister("DMPlexCoordinatesLoad", DM_CLASSID, &DMPLEX_CoordinatesLoad);
124:   PetscLogEventRegister("DMPlexSectionLoad", DM_CLASSID, &DMPLEX_SectionLoad);
125:   PetscLogEventRegister("DMPlexGlobalVectorLoad", DM_CLASSID, &DMPLEX_GlobalVectorLoad);
126:   PetscLogEventRegister("DMPlexLocalVectorLoad", DM_CLASSID, &DMPLEX_LocalVectorLoad);
127:   PetscLogEventRegister("DMPlexMetricEnforceSPD", DM_CLASSID, &DMPLEX_MetricEnforceSPD);
128:   PetscLogEventRegister("DMPlexMetricNormalize", DM_CLASSID, &DMPLEX_MetricNormalize);
129:   PetscLogEventRegister("DMPlexMetricAverage", DM_CLASSID, &DMPLEX_MetricAverage);
130:   PetscLogEventRegister("DMPlexMetricIntersect", DM_CLASSID, &DMPLEX_MetricIntersection);

132:   PetscLogEventRegister("RebalBuildGraph", DM_CLASSID, &DMPLEX_RebalBuildGraph);
133:   PetscLogEventRegister("RebalGatherGraph", DM_CLASSID, &DMPLEX_RebalGatherGraph);
134:   PetscLogEventRegister("RebalPartition", DM_CLASSID, &DMPLEX_RebalPartition);
135:   PetscLogEventRegister("RebalScatterPart", DM_CLASSID, &DMPLEX_RebalScatterPart);
136:   PetscLogEventRegister("RebalRewriteSF", DM_CLASSID, &DMPLEX_RebalRewriteSF);

138:   PetscLogEventRegister("DMSwarmMigrate", DM_CLASSID, &DMSWARM_Migrate);
139:   PetscLogEventRegister("DMSwarmDETSetup", DM_CLASSID, &DMSWARM_DataExchangerTopologySetup);
140:   PetscLogEventRegister("DMSwarmDExBegin", DM_CLASSID, &DMSWARM_DataExchangerBegin);
141:   PetscLogEventRegister("DMSwarmDExEnd", DM_CLASSID, &DMSWARM_DataExchangerEnd);
142:   PetscLogEventRegister("DMSwarmDESendCnt", DM_CLASSID, &DMSWARM_DataExchangerSendCount);
143:   PetscLogEventRegister("DMSwarmDEPack", DM_CLASSID, &DMSWARM_DataExchangerPack);
144:   PetscLogEventRegister("DMSwarmAddPnts", DM_CLASSID, &DMSWARM_AddPoints);
145:   PetscLogEventRegister("DMSwarmRmvPnts", DM_CLASSID, &DMSWARM_RemovePoints);
146:   PetscLogEventRegister("DMSwarmSort", DM_CLASSID, &DMSWARM_Sort);
147:   PetscLogEventRegister("DMSwarmSetSizes", DM_CLASSID, &DMSWARM_SetSizes);

149:   PetscLogEventRegister("DMNtLayoutSetUp", DM_CLASSID, &DMNetwork_LayoutSetUp);
150:   PetscLogEventRegister("DMNtSetUp", DM_CLASSID, &DMNetwork_SetUpNetwork);
151:   PetscLogEventRegister("DMNtDistribute", DM_CLASSID, &DMNetwork_Distribute);
152:   /* Process Info */
153:   {
154:     PetscClassId classids[1];

156:     classids[0] = DM_CLASSID;
157:     PetscInfoProcessClass("dm", 1, classids);
158:   }

160:   /* Process summary exclusions */
161:   PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt);
162:   if (opt) {
163:     PetscStrInList("dm", logList, ',', &pkg);
164:     if (pkg) PetscLogEventExcludeClass(DM_CLASSID);
165:   }

167:   DMGenerateRegisterAll();
168:   PetscRegisterFinalize(DMGenerateRegisterDestroy);
169:   DMPlexTransformRegisterAll();
170:   PetscRegisterFinalize(DMPlexTransformRegisterDestroy);
171:   PetscRegisterFinalize(DMFinalizePackage);
172:   return 0;
173: }
174: #include <petscfe.h>

176: static PetscBool PetscFEPackageInitialized = PETSC_FALSE;
177: /*@C
178:   PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called
179:   from PetscFinalize().

181:   Level: developer

183: .seealso: `PetscInitialize()`
184: @*/
185: PetscErrorCode PetscFEFinalizePackage(void)
186: {
187:   PetscFunctionListDestroy(&PetscSpaceList);
188:   PetscFunctionListDestroy(&PetscDualSpaceList);
189:   PetscFunctionListDestroy(&PetscFEList);
190:   PetscFEPackageInitialized       = PETSC_FALSE;
191:   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
192:   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
193:   PetscFERegisterAllCalled        = PETSC_FALSE;
194:   return 0;
195: }

197: /*@C
198:   PetscFEInitializePackage - This function initializes everything in the FE package. It is called
199:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate()
200:   when using static libraries.

202:   Level: developer

204: .seealso: `PetscInitialize()`
205: @*/
206: PetscErrorCode PetscFEInitializePackage(void)
207: {
208:   char      logList[256];
209:   PetscBool opt, pkg;

211:   if (PetscFEPackageInitialized) return 0;
212:   PetscFEPackageInitialized = PETSC_TRUE;

214:   /* Register Classes */
215:   PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);
216:   PetscClassIdRegister("Dual Space", &PETSCDUALSPACE_CLASSID);
217:   PetscClassIdRegister("FE Space", &PETSCFE_CLASSID);
218:   /* Register Constructors */
219:   PetscSpaceRegisterAll();
220:   PetscDualSpaceRegisterAll();
221:   PetscFERegisterAll();
222:   /* Register Events */
223:   PetscLogEventRegister("DualSpaceSetUp", PETSCDUALSPACE_CLASSID, &PETSCDUALSPACE_SetUp);
224:   PetscLogEventRegister("FESetUp", PETSCFE_CLASSID, &PETSCFE_SetUp);
225:   /* Process Info */
226:   {
227:     PetscClassId classids[3];

229:     classids[0] = PETSCFE_CLASSID;
230:     classids[1] = PETSCSPACE_CLASSID;
231:     classids[2] = PETSCDUALSPACE_CLASSID;
232:     PetscInfoProcessClass("fe", 1, classids);
233:     PetscInfoProcessClass("space", 1, &classids[1]);
234:     PetscInfoProcessClass("dualspace", 1, &classids[2]);
235:   }
236:   /* Process summary exclusions */
237:   PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt);
238:   if (opt) {
239:     PetscStrInList("fe", logList, ',', &pkg);
240:     if (pkg) PetscLogEventExcludeClass(PETSCFE_CLASSID);
241:   }
242:   /* Register package finalizer */
243:   PetscRegisterFinalize(PetscFEFinalizePackage);
244:   return 0;
245: }
246: #include <petscfv.h>

248: static PetscBool PetscFVPackageInitialized = PETSC_FALSE;
249: /*@C
250:   PetscFVFinalizePackage - This function finalizes everything in the PetscFV package. It is called
251:   from PetscFinalize().

253:   Level: developer

255: .seealso: `PetscInitialize()`
256: @*/
257: PetscErrorCode PetscFVFinalizePackage(void)
258: {
259:   PetscFunctionListDestroy(&PetscLimiterList);
260:   PetscFunctionListDestroy(&PetscFVList);
261:   PetscFVPackageInitialized     = PETSC_FALSE;
262:   PetscFVRegisterAllCalled      = PETSC_FALSE;
263:   PetscLimiterRegisterAllCalled = PETSC_FALSE;
264:   return 0;
265: }

267: /*@C
268:   PetscFVInitializePackage - This function initializes everything in the FV package. It is called
269:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscFVCreate()
270:   when using static libraries.

272:   Level: developer

274: .seealso: `PetscInitialize()`
275: @*/
276: PetscErrorCode PetscFVInitializePackage(void)
277: {
278:   char      logList[256];
279:   PetscBool opt, pkg;

281:   if (PetscFVPackageInitialized) return 0;
282:   PetscFVPackageInitialized = PETSC_TRUE;

284:   /* Register Classes */
285:   PetscClassIdRegister("FV Space", &PETSCFV_CLASSID);
286:   PetscClassIdRegister("Limiter", &PETSCLIMITER_CLASSID);
287:   /* Register Constructors */
288:   PetscFVRegisterAll();
289:   /* Register Events */
290:   /* Process Info */
291:   {
292:     PetscClassId classids[2];

294:     classids[0] = PETSCFV_CLASSID;
295:     classids[1] = PETSCLIMITER_CLASSID;
296:     PetscInfoProcessClass("fv", 1, classids);
297:     PetscInfoProcessClass("limiter", 1, &classids[1]);
298:   }
299:   /* Process summary exclusions */
300:   PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt);
301:   if (opt) {
302:     PetscStrInList("fv", logList, ',', &pkg);
303:     if (pkg) PetscLogEventExcludeClass(PETSCFV_CLASSID);
304:     PetscStrInList("limiter", logList, ',', &pkg);
305:     if (pkg) PetscLogEventExcludeClass(PETSCLIMITER_CLASSID);
306:   }
307:   /* Register package finalizer */
308:   PetscRegisterFinalize(PetscFVFinalizePackage);
309:   return 0;
310: }
311: #include <petscds.h>

313: static PetscBool PetscDSPackageInitialized = PETSC_FALSE;
314: /*@C
315:   PetscDSFinalizePackage - This function finalizes everything in the PetscDS package. It is called
316:   from PetscFinalize().

318:   Level: developer

320: .seealso: `PetscInitialize()`
321: @*/
322: PetscErrorCode PetscDSFinalizePackage(void)
323: {
324:   PetscFunctionListDestroy(&PetscDSList);
325:   PetscDSPackageInitialized = PETSC_FALSE;
326:   PetscDSRegisterAllCalled  = PETSC_FALSE;
327:   return 0;
328: }

330: /*@C
331:   PetscDSInitializePackage - This function initializes everything in the DS package. It is called
332:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscDSCreate()
333:   when using static libraries.

335:   Level: developer

337: .seealso: `PetscInitialize()`
338: @*/
339: PetscErrorCode PetscDSInitializePackage(void)
340: {
341:   char      logList[256];
342:   PetscBool opt, pkg;

344:   if (PetscDSPackageInitialized) return 0;
345:   PetscDSPackageInitialized = PETSC_TRUE;

347:   /* Register Classes */
348:   PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID);
349:   PetscClassIdRegister("Weak Form", &PETSCWEAKFORM_CLASSID);
350:   /* Register Constructors */
351:   PetscDSRegisterAll();
352:   /* Register Events */
353:   /* Process Info */
354:   {
355:     PetscClassId classids[1];

357:     classids[0] = PETSCDS_CLASSID;
358:     PetscInfoProcessClass("ds", 1, classids);
359:   }
360:   /* Process summary exclusions */
361:   PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt);
362:   if (opt) {
363:     PetscStrInList("ds", logList, ',', &pkg);
364:     if (pkg) PetscLogEventExcludeClass(PETSCDS_CLASSID);
365:   }
366:   /* Register package finalizer */
367:   PetscRegisterFinalize(PetscDSFinalizePackage);
368:   return 0;
369: }

371: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
372: /*
373:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

378: */
379: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
380: {
381:   AOInitializePackage();
382:   PetscPartitionerInitializePackage();
383:   DMInitializePackage();
384:   PetscFEInitializePackage();
385:   PetscFVInitializePackage();
386:   DMFieldInitializePackage();
387:   return 0;
388: }

390: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */