Date: 2026-03-31T05:46:12+00:00

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));
     61:   PetscCall(PetscClassIdRegister("Swarm Cell DM", &DMSWARMCELLDM_CLASSID));

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

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

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

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

    155:   PetscCall(PetscLogEventRegister("DMPlexTrSetUp", DM_CLASSID, &DMPLEXTRANSFORM_SetUp));
    156:   PetscCall(PetscLogEventRegister("DMPlexTrApply", DM_CLASSID, &DMPLEXTRANSFORM_Apply));
    157:   PetscCall(PetscLogEventRegister("DMPlexTrSizes", DM_CLASSID, &DMPLEXTRANSFORM_SetConeSizes));
    158:   PetscCall(PetscLogEventRegister("DMPlexTrCones", DM_CLASSID, &DMPLEXTRANSFORM_SetCones));
    159:   PetscCall(PetscLogEventRegister("DMPlexTrSF", DM_CLASSID, &DMPLEXTRANSFORM_CreateSF));
    160:   PetscCall(PetscLogEventRegister("DMPlexTrLabels", DM_CLASSID, &DMPLEXTRANSFORM_CreateLabels));
    161:   PetscCall(PetscLogEventRegister("DMPlexTrCoords", DM_CLASSID, &DMPLEXTRANSFORM_SetCoordinates));

    163:   PetscCall(PetscLogEventRegister("DMSwarmMigrate", DM_CLASSID, &DMSWARM_Migrate));
    164:   PetscCall(PetscLogEventRegister("DMSwarmDETSetup", DM_CLASSID, &DMSWARM_DataExchangerTopologySetup));
    165:   PetscCall(PetscLogEventRegister("DMSwarmDExBegin", DM_CLASSID, &DMSWARM_DataExchangerBegin));
    166:   PetscCall(PetscLogEventRegister("DMSwarmDExEnd", DM_CLASSID, &DMSWARM_DataExchangerEnd));
    167:   PetscCall(PetscLogEventRegister("DMSwarmDESendCnt", DM_CLASSID, &DMSWARM_DataExchangerSendCount));
    168:   PetscCall(PetscLogEventRegister("DMSwarmDEPack", DM_CLASSID, &DMSWARM_DataExchangerPack));
    169:   PetscCall(PetscLogEventRegister("DMSwarmAddPnts", DM_CLASSID, &DMSWARM_AddPoints));
    170:   PetscCall(PetscLogEventRegister("DMSwarmRmvPnts", DM_CLASSID, &DMSWARM_RemovePoints));
    171:   PetscCall(PetscLogEventRegister("DMSwarmSort", DM_CLASSID, &DMSWARM_Sort));
    172:   PetscCall(PetscLogEventRegister("DMSwarmSetSizes", DM_CLASSID, &DMSWARM_SetSizes));

    174:   PetscCall(PetscLogEventRegister("DMNtLayoutSetUp", DM_CLASSID, &DMNetwork_LayoutSetUp));
    175:   PetscCall(PetscLogEventRegister("DMNtSetUp", DM_CLASSID, &DMNetwork_SetUpNetwork));
    176:   PetscCall(PetscLogEventRegister("DMNtDistribute", DM_CLASSID, &DMNetwork_Distribute));
    177:   /* Process Info */
    178:   {
    179:     PetscClassId classids[1];

    181:     classids[0] = DM_CLASSID;
    182:     PetscCall(PetscInfoProcessClass("dm", 1, classids));
    183:   }

    185:   /* Process summary exclusions */
    186:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    187:   if (opt) {
    188:     PetscCall(PetscStrInList("dm", logList, ',', &pkg));
    189:     if (pkg) PetscCall(PetscLogEventExcludeClass(DM_CLASSID));
    190:   }

    192:   PetscCall(DMGenerateRegisterAll());
    193:   PetscCall(PetscRegisterFinalize(DMGenerateRegisterDestroy));
    194:   PetscCall(DMGeomModelRegisterAll());
    195:   PetscCall(PetscRegisterFinalize(DMGeomModelRegisterDestroy));
    196:   PetscCall(DMPlexTransformRegisterAll());
    197:   PetscCall(PetscRegisterFinalize(DMPlexTransformRegisterDestroy));
    198:   PetscCall(DMLabelRegisterAll());
    199:   PetscCall(PetscRegisterFinalize(DMLabelRegisterDestroy));
    200:   PetscCall(PetscRegisterFinalize(DMFinalizePackage));
    201:   PetscFunctionReturn(PETSC_SUCCESS);
    202: }
    203: #include <petscfe.h>

    205: static PetscBool PetscFEPackageInitialized = PETSC_FALSE;

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

    211:   Level: developer

    213: .seealso: `PetscInitialize()`
    214: @*/
    215: PetscErrorCode PetscFEFinalizePackage(void)
    216: {
    217:   PetscFunctionBegin;
    218:   PetscCall(PetscFunctionListDestroy(&PetscSpaceList));
    219:   PetscCall(PetscFunctionListDestroy(&PetscDualSpaceList));
    220:   PetscCall(PetscFunctionListDestroy(&PetscFEList));
    221:   PetscFEPackageInitialized       = PETSC_FALSE;
    222:   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
    223:   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
    224:   PetscFERegisterAllCalled        = PETSC_FALSE;
    225:   PetscFunctionReturn(PETSC_SUCCESS);
    226: }

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

    233:   Level: developer

    235: .seealso: `PetscInitialize()`
    236: @*/
    237: PetscErrorCode PetscFEInitializePackage(void)
    238: {
    239:   char      logList[256];
    240:   PetscBool opt, pkg;

    242:   PetscFunctionBegin;
    243:   if (PetscFEPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    244:   PetscFEPackageInitialized = PETSC_TRUE;

    246:   /* Register Classes */
    247:   PetscCall(PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID));
    248:   PetscCall(PetscClassIdRegister("Dual Space", &PETSCDUALSPACE_CLASSID));
    249:   PetscCall(PetscClassIdRegister("FE Space", &PETSCFE_CLASSID));
    250:   /* Register Constructors */
    251:   PetscCall(PetscSpaceRegisterAll());
    252:   PetscCall(PetscDualSpaceRegisterAll());
    253:   PetscCall(PetscFERegisterAll());
    254:   /* Register Events */
    255:   PetscCall(PetscLogEventRegister("DualSpaceSetUp", PETSCDUALSPACE_CLASSID, &PETSCDUALSPACE_SetUp));
    256:   PetscCall(PetscLogEventRegister("FESetUp", PETSCFE_CLASSID, &PETSCFE_SetUp));
    257:   /* Process Info */
    258:   {
    259:     PetscClassId classids[3];

    261:     classids[0] = PETSCFE_CLASSID;
    262:     classids[1] = PETSCSPACE_CLASSID;
    263:     classids[2] = PETSCDUALSPACE_CLASSID;
    264:     PetscCall(PetscInfoProcessClass("fe", 1, classids));
    265:     PetscCall(PetscInfoProcessClass("space", 1, &classids[1]));
    266:     PetscCall(PetscInfoProcessClass("dualspace", 1, &classids[2]));
    267:   }
    268:   /* Process summary exclusions */
    269:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    270:   if (opt) {
    271:     PetscCall(PetscStrInList("fe", logList, ',', &pkg));
    272:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCFE_CLASSID));
    273:   }
    274:   /* Register package finalizer */
    275:   PetscCall(PetscRegisterFinalize(PetscFEFinalizePackage));
    276:   PetscFunctionReturn(PETSC_SUCCESS);
    277: }
    278: #include <petscfv.h>

    280: static PetscBool PetscFVPackageInitialized = PETSC_FALSE;

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

    286:   Level: developer

    288: .seealso: `PetscInitialize()`
    289: @*/
    290: PetscErrorCode PetscFVFinalizePackage(void)
    291: {
    292:   PetscFunctionBegin;
    293:   PetscCall(PetscFunctionListDestroy(&PetscLimiterList));
    294:   PetscCall(PetscFunctionListDestroy(&PetscFVList));
    295:   PetscFVPackageInitialized     = PETSC_FALSE;
    296:   PetscFVRegisterAllCalled      = PETSC_FALSE;
    297:   PetscLimiterRegisterAllCalled = PETSC_FALSE;
    298:   PetscFunctionReturn(PETSC_SUCCESS);
    299: }

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

    306:   Level: developer

    308: .seealso: `PetscInitialize()`
    309: @*/
    310: PetscErrorCode PetscFVInitializePackage(void)
    311: {
    312:   char      logList[256];
    313:   PetscBool opt, pkg;

    315:   PetscFunctionBegin;
    316:   if (PetscFVPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    317:   PetscFVPackageInitialized = PETSC_TRUE;

    319:   /* Register Classes */
    320:   PetscCall(PetscClassIdRegister("FV Space", &PETSCFV_CLASSID));
    321:   PetscCall(PetscClassIdRegister("Limiter", &PETSCLIMITER_CLASSID));
    322:   /* Register Constructors */
    323:   PetscCall(PetscFVRegisterAll());
    324:   /* Register Events */
    325:   /* Process Info */
    326:   {
    327:     PetscClassId classids[2];

    329:     classids[0] = PETSCFV_CLASSID;
    330:     classids[1] = PETSCLIMITER_CLASSID;
    331:     PetscCall(PetscInfoProcessClass("fv", 1, classids));
    332:     PetscCall(PetscInfoProcessClass("limiter", 1, &classids[1]));
    333:   }
    334:   /* Process summary exclusions */
    335:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    336:   if (opt) {
    337:     PetscCall(PetscStrInList("fv", logList, ',', &pkg));
    338:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCFV_CLASSID));
    339:     PetscCall(PetscStrInList("limiter", logList, ',', &pkg));
    340:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCLIMITER_CLASSID));
    341:   }
    342:   /* Register package finalizer */
    343:   PetscCall(PetscRegisterFinalize(PetscFVFinalizePackage));
    344:   PetscFunctionReturn(PETSC_SUCCESS);
    345: }
    346: #include <petscds.h>

    348: static PetscBool PetscDSPackageInitialized = PETSC_FALSE;

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

    354:   Level: developer

    356: .seealso: `PetscInitialize()`
    357: @*/
    358: PetscErrorCode PetscDSFinalizePackage(void)
    359: {
    360:   PetscFunctionBegin;
    361:   PetscCall(PetscFunctionListDestroy(&PetscDSList));
    362:   PetscDSPackageInitialized = PETSC_FALSE;
    363:   PetscDSRegisterAllCalled  = PETSC_FALSE;
    364:   PetscFunctionReturn(PETSC_SUCCESS);
    365: }

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

    372:   Level: developer

    374: .seealso: `PetscInitialize()`
    375: @*/
    376: PetscErrorCode PetscDSInitializePackage(void)
    377: {
    378:   char      logList[256];
    379:   PetscBool opt, pkg;

    381:   PetscFunctionBegin;
    382:   if (PetscDSPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    383:   PetscDSPackageInitialized = PETSC_TRUE;

    385:   /* Register Classes */
    386:   PetscCall(PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID));
    387:   PetscCall(PetscClassIdRegister("Weak Form", &PETSCWEAKFORM_CLASSID));
    388:   /* Register Constructors */
    389:   PetscCall(PetscDSRegisterAll());
    390:   /* Register Events */
    391:   /* Process Info */
    392:   {
    393:     PetscClassId classids[1];

    395:     classids[0] = PETSCDS_CLASSID;
    396:     PetscCall(PetscInfoProcessClass("ds", 1, classids));
    397:   }
    398:   /* Process summary exclusions */
    399:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
    400:   if (opt) {
    401:     PetscCall(PetscStrInList("ds", logList, ',', &pkg));
    402:     if (pkg) PetscCall(PetscLogEventExcludeClass(PETSCDS_CLASSID));
    403:   }
    404:   /* Register package finalizer */
    405:   PetscCall(PetscRegisterFinalize(PetscDSFinalizePackage));
    406:   PetscFunctionReturn(PETSC_SUCCESS);
    407: }

    409: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
    410: /*
    411:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

    416: */
    417: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
    418: {
    419:   PetscFunctionBegin;
    420:   PetscCall(AOInitializePackage());
    421:   PetscCall(PetscPartitionerInitializePackage());
    422:   PetscCall(DMInitializePackage());
    423:   PetscCall(PetscFEInitializePackage());
    424:   PetscCall(PetscFVInitializePackage());
    425:   PetscCall(DMFieldInitializePackage());
    426:   PetscCall(PetscDSInitializePackage());
    427:   PetscFunctionReturn(PETSC_SUCCESS);
    428: }

    430: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */