Actual source code: dlregisdmdm.c

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

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

     17:   Level: developer

     19: .seealso: `PetscInitialize()`
     20: @*/
     21: PetscErrorCode DMFinalizePackage(void)
     22: {
     23:   PetscFunctionBegin;
     24:   PetscCall(PetscFunctionListDestroy(&DMList));
     25:   DMPackageInitialized = PETSC_FALSE;
     26:   DMRegisterAllCalled  = PETSC_FALSE;
     27:   PetscFunctionReturn(PETSC_SUCCESS);
     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 `DMCreate()`
     38:   or similar routines when using shared or static libraries.

     40:   Level: developer

     42:   Note:
     43:   This function never needs to be called by PETSc users.

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

     52:   PetscFunctionBegin;
     53:   if (DMPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
     54:   DMPackageInitialized = PETSC_TRUE;

     56:   /* Register Classes */
     57:   PetscCall(PetscClassIdRegister("Distributed Mesh", &DM_CLASSID));
     58:   PetscCall(PetscClassIdRegister("DM Label", &DMLABEL_CLASSID));
     59:   PetscCall(PetscClassIdRegister("Quadrature", &PETSCQUADRATURE_CLASSID));
     60:   PetscCall(PetscClassIdRegister("Mesh Transform", &DMPLEXTRANSFORM_CLASSID));

     62: #if defined(PETSC_HAVE_HYPRE)
     63:   PetscCall(MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct));
     64:   PetscCall(MatRegister(MATHYPRESSTRUCT, MatCreate_HYPRESStruct));
     65: #endif
     66:   PetscCall(PetscSectionSymRegister(PETSCSECTIONSYMLABEL, PetscSectionSymCreate_Label));

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

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

    145:   PetscCall(PetscLogEventRegister("RebalBuildGraph", DM_CLASSID, &DMPLEX_RebalBuildGraph));
    146:   PetscCall(PetscLogEventRegister("RebalGatherGraph", DM_CLASSID, &DMPLEX_RebalGatherGraph));
    147:   PetscCall(PetscLogEventRegister("RebalPartition", DM_CLASSID, &DMPLEX_RebalPartition));
    148:   PetscCall(PetscLogEventRegister("RebalScatterPart", DM_CLASSID, &DMPLEX_RebalScatterPart));
    149:   PetscCall(PetscLogEventRegister("RebalRewriteSF", DM_CLASSID, &DMPLEX_RebalRewriteSF));
    150:   PetscCall(PetscLogEventRegister("DMPlexUninterp", DM_CLASSID, &DMPLEX_Uninterpolate));

    152:   PetscCall(PetscLogEventRegister("DMSwarmMigrate", DM_CLASSID, &DMSWARM_Migrate));
    153:   PetscCall(PetscLogEventRegister("DMSwarmDETSetup", DM_CLASSID, &DMSWARM_DataExchangerTopologySetup));
    154:   PetscCall(PetscLogEventRegister("DMSwarmDExBegin", DM_CLASSID, &DMSWARM_DataExchangerBegin));
    155:   PetscCall(PetscLogEventRegister("DMSwarmDExEnd", DM_CLASSID, &DMSWARM_DataExchangerEnd));
    156:   PetscCall(PetscLogEventRegister("DMSwarmDESendCnt", DM_CLASSID, &DMSWARM_DataExchangerSendCount));
    157:   PetscCall(PetscLogEventRegister("DMSwarmDEPack", DM_CLASSID, &DMSWARM_DataExchangerPack));
    158:   PetscCall(PetscLogEventRegister("DMSwarmAddPnts", DM_CLASSID, &DMSWARM_AddPoints));
    159:   PetscCall(PetscLogEventRegister("DMSwarmRmvPnts", DM_CLASSID, &DMSWARM_RemovePoints));
    160:   PetscCall(PetscLogEventRegister("DMSwarmSort", DM_CLASSID, &DMSWARM_Sort));
    161:   PetscCall(PetscLogEventRegister("DMSwarmSetSizes", DM_CLASSID, &DMSWARM_SetSizes));

    163:   PetscCall(PetscLogEventRegister("DMNtLayoutSetUp", DM_CLASSID, &DMNetwork_LayoutSetUp));
    164:   PetscCall(PetscLogEventRegister("DMNtSetUp", DM_CLASSID, &DMNetwork_SetUpNetwork));
    165:   PetscCall(PetscLogEventRegister("DMNtDistribute", DM_CLASSID, &DMNetwork_Distribute));
    166:   /* Process Info */
    167:   {
    168:     PetscClassId classids[1];

    170:     classids[0] = DM_CLASSID;
    171:     PetscCall(PetscInfoProcessClass("dm", 1, classids));
    172:   }

    174:   /* Process summary exclusions */
    175:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    176:   if (opt) {
    177:     PetscCall(PetscStrInList("dm", logList, ',', &pkg));
    178:     if (pkg) PetscCall(PetscLogEventExcludeClass(DM_CLASSID));
    179:   }

    181:   PetscCall(DMGenerateRegisterAll());
    182:   PetscCall(PetscRegisterFinalize(DMGenerateRegisterDestroy));
    183:   PetscCall(DMGeomModelRegisterAll());
    184:   PetscCall(PetscRegisterFinalize(DMGeomModelRegisterDestroy));
    185:   PetscCall(DMPlexTransformRegisterAll());
    186:   PetscCall(PetscRegisterFinalize(DMPlexTransformRegisterDestroy));
    187:   PetscCall(DMLabelRegisterAll());
    188:   PetscCall(PetscRegisterFinalize(DMLabelRegisterDestroy));
    189:   PetscCall(PetscRegisterFinalize(DMFinalizePackage));
    190:   PetscFunctionReturn(PETSC_SUCCESS);
    191: }
    192: #include <petscfe.h>

    194: static PetscBool PetscFEPackageInitialized = PETSC_FALSE;

    196: /*@C
    197:   PetscFEFinalizePackage - This function finalizes everything in the `PetscFE` package. It is called
    198:   from `PetscFinalize()`.

    200:   Level: developer

    202: .seealso: `PetscInitialize()`
    203: @*/
    204: PetscErrorCode PetscFEFinalizePackage(void)
    205: {
    206:   PetscFunctionBegin;
    207:   PetscCall(PetscFunctionListDestroy(&PetscSpaceList));
    208:   PetscCall(PetscFunctionListDestroy(&PetscDualSpaceList));
    209:   PetscCall(PetscFunctionListDestroy(&PetscFEList));
    210:   PetscFEPackageInitialized       = PETSC_FALSE;
    211:   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
    212:   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
    213:   PetscFERegisterAllCalled        = PETSC_FALSE;
    214:   PetscFunctionReturn(PETSC_SUCCESS);
    215: }

    217: /*@C
    218:   PetscFEInitializePackage - This function initializes everything in the `PetscFE` package. It is called
    219:   from `PetscDLLibraryRegister()` when using dynamic libraries, and on the first call to `PetscSpaceCreate()`
    220:   when using static libraries.

    222:   Level: developer

    224: .seealso: `PetscInitialize()`
    225: @*/
    226: PetscErrorCode PetscFEInitializePackage(void)
    227: {
    228:   char      logList[256];
    229:   PetscBool opt, pkg;

    231:   PetscFunctionBegin;
    232:   if (PetscFEPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    233:   PetscFEPackageInitialized = PETSC_TRUE;

    235:   /* Register Classes */
    236:   PetscCall(PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID));
    237:   PetscCall(PetscClassIdRegister("Dual Space", &PETSCDUALSPACE_CLASSID));
    238:   PetscCall(PetscClassIdRegister("FE Space", &PETSCFE_CLASSID));
    239:   /* Register Constructors */
    240:   PetscCall(PetscSpaceRegisterAll());
    241:   PetscCall(PetscDualSpaceRegisterAll());
    242:   PetscCall(PetscFERegisterAll());
    243:   /* Register Events */
    244:   PetscCall(PetscLogEventRegister("DualSpaceSetUp", PETSCDUALSPACE_CLASSID, &PETSCDUALSPACE_SetUp));
    245:   PetscCall(PetscLogEventRegister("FESetUp", PETSCFE_CLASSID, &PETSCFE_SetUp));
    246:   /* Process Info */
    247:   {
    248:     PetscClassId classids[3];

    250:     classids[0] = PETSCFE_CLASSID;
    251:     classids[1] = PETSCSPACE_CLASSID;
    252:     classids[2] = PETSCDUALSPACE_CLASSID;
    253:     PetscCall(PetscInfoProcessClass("fe", 1, classids));
    254:     PetscCall(PetscInfoProcessClass("space", 1, &classids[1]));
    255:     PetscCall(PetscInfoProcessClass("dualspace", 1, &classids[2]));
    256:   }
    257:   /* Process summary exclusions */
    258:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    259:   if (opt) {
    260:     PetscCall(PetscStrInList("fe", logList, ',', &pkg));
    261:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCFE_CLASSID));
    262:   }
    263:   /* Register package finalizer */
    264:   PetscCall(PetscRegisterFinalize(PetscFEFinalizePackage));
    265:   PetscFunctionReturn(PETSC_SUCCESS);
    266: }
    267: #include <petscfv.h>

    269: static PetscBool PetscFVPackageInitialized = PETSC_FALSE;

    271: /*@C
    272:   PetscFVFinalizePackage - This function finalizes everything in the `PetscFV` package. It is called
    273:   from `PetscFinalize()`.

    275:   Level: developer

    277: .seealso: `PetscInitialize()`
    278: @*/
    279: PetscErrorCode PetscFVFinalizePackage(void)
    280: {
    281:   PetscFunctionBegin;
    282:   PetscCall(PetscFunctionListDestroy(&PetscLimiterList));
    283:   PetscCall(PetscFunctionListDestroy(&PetscFVList));
    284:   PetscFVPackageInitialized     = PETSC_FALSE;
    285:   PetscFVRegisterAllCalled      = PETSC_FALSE;
    286:   PetscLimiterRegisterAllCalled = PETSC_FALSE;
    287:   PetscFunctionReturn(PETSC_SUCCESS);
    288: }

    290: /*@C
    291:   PetscFVInitializePackage - This function initializes everything in the `PetscFV` package. It is called
    292:   from `PetscDLLibraryRegister()` when using dynamic libraries, and on the first call to `PetscFVCreate()`
    293:   when using static libraries.

    295:   Level: developer

    297: .seealso: `PetscInitialize()`
    298: @*/
    299: PetscErrorCode PetscFVInitializePackage(void)
    300: {
    301:   char      logList[256];
    302:   PetscBool opt, pkg;

    304:   PetscFunctionBegin;
    305:   if (PetscFVPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    306:   PetscFVPackageInitialized = PETSC_TRUE;

    308:   /* Register Classes */
    309:   PetscCall(PetscClassIdRegister("FV Space", &PETSCFV_CLASSID));
    310:   PetscCall(PetscClassIdRegister("Limiter", &PETSCLIMITER_CLASSID));
    311:   /* Register Constructors */
    312:   PetscCall(PetscFVRegisterAll());
    313:   /* Register Events */
    314:   /* Process Info */
    315:   {
    316:     PetscClassId classids[2];

    318:     classids[0] = PETSCFV_CLASSID;
    319:     classids[1] = PETSCLIMITER_CLASSID;
    320:     PetscCall(PetscInfoProcessClass("fv", 1, classids));
    321:     PetscCall(PetscInfoProcessClass("limiter", 1, &classids[1]));
    322:   }
    323:   /* Process summary exclusions */
    324:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    325:   if (opt) {
    326:     PetscCall(PetscStrInList("fv", logList, ',', &pkg));
    327:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCFV_CLASSID));
    328:     PetscCall(PetscStrInList("limiter", logList, ',', &pkg));
    329:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCLIMITER_CLASSID));
    330:   }
    331:   /* Register package finalizer */
    332:   PetscCall(PetscRegisterFinalize(PetscFVFinalizePackage));
    333:   PetscFunctionReturn(PETSC_SUCCESS);
    334: }
    335: #include <petscds.h>

    337: static PetscBool PetscDSPackageInitialized = PETSC_FALSE;

    339: /*@C
    340:   PetscDSFinalizePackage - This function finalizes everything in the `PetscDS` package. It is called
    341:   from `PetscFinalize()`.

    343:   Level: developer

    345: .seealso: `PetscInitialize()`
    346: @*/
    347: PetscErrorCode PetscDSFinalizePackage(void)
    348: {
    349:   PetscFunctionBegin;
    350:   PetscCall(PetscFunctionListDestroy(&PetscDSList));
    351:   PetscDSPackageInitialized = PETSC_FALSE;
    352:   PetscDSRegisterAllCalled  = PETSC_FALSE;
    353:   PetscFunctionReturn(PETSC_SUCCESS);
    354: }

    356: /*@C
    357:   PetscDSInitializePackage - This function initializes everything in the `PetscDS` package. It is called
    358:   from `PetscDLLibraryRegister()` when using dynamic libraries, and on the first call to `PetscDSCreate()`
    359:   when using static libraries.

    361:   Level: developer

    363: .seealso: `PetscInitialize()`
    364: @*/
    365: PetscErrorCode PetscDSInitializePackage(void)
    366: {
    367:   char      logList[256];
    368:   PetscBool opt, pkg;

    370:   PetscFunctionBegin;
    371:   if (PetscDSPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    372:   PetscDSPackageInitialized = PETSC_TRUE;

    374:   /* Register Classes */
    375:   PetscCall(PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID));
    376:   PetscCall(PetscClassIdRegister("Weak Form", &PETSCWEAKFORM_CLASSID));
    377:   /* Register Constructors */
    378:   PetscCall(PetscDSRegisterAll());
    379:   /* Register Events */
    380:   /* Process Info */
    381:   {
    382:     PetscClassId classids[1];

    384:     classids[0] = PETSCDS_CLASSID;
    385:     PetscCall(PetscInfoProcessClass("ds", 1, classids));
    386:   }
    387:   /* Process summary exclusions */
    388:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    389:   if (opt) {
    390:     PetscCall(PetscStrInList("ds", logList, ',', &pkg));
    391:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCDS_CLASSID));
    392:   }
    393:   /* Register package finalizer */
    394:   PetscCall(PetscRegisterFinalize(PetscDSFinalizePackage));
    395:   PetscFunctionReturn(PETSC_SUCCESS);
    396: }

    398: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
    399: /*
    400:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

    405: */
    406: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
    407: {
    408:   PetscFunctionBegin;
    409:   PetscCall(AOInitializePackage());
    410:   PetscCall(PetscPartitionerInitializePackage());
    411:   PetscCall(DMInitializePackage());
    412:   PetscCall(PetscFEInitializePackage());
    413:   PetscCall(PetscFVInitializePackage());
    414:   PetscCall(DMFieldInitializePackage());
    415:   PetscCall(PetscDSInitializePackage());
    416:   PetscFunctionReturn(PETSC_SUCCESS);
    417: }

    419: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */