Date: 2025-03-29T05:58:24+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("DMPlexDistCones", DM_CLASSID, &DMPLEX_DistributeCones));
    104:   PetscCall(PetscLogEventRegister("DMPlexDistLabels", DM_CLASSID, &DMPLEX_DistributeLabels));
    105:   PetscCall(PetscLogEventRegister("DMPlexDistSF", DM_CLASSID, &DMPLEX_DistributeSF));
    106:   PetscCall(PetscLogEventRegister("DMPlexDistOvrlp", DM_CLASSID, &DMPLEX_DistributeOverlap));
    107:   PetscCall(PetscLogEventRegister("DMPlexDistField", DM_CLASSID, &DMPLEX_DistributeField));
    108:   PetscCall(PetscLogEventRegister("DMPlexDistData", DM_CLASSID, &DMPLEX_DistributeData));
    109:   PetscCall(PetscLogEventRegister("DMPlexInterpSF", DM_CLASSID, &DMPLEX_InterpolateSF));
    110:   PetscCall(PetscLogEventRegister("DMPlexGToNBegin", DM_CLASSID, &DMPLEX_GlobalToNaturalBegin));
    111:   PetscCall(PetscLogEventRegister("DMPlexGToNEnd", DM_CLASSID, &DMPLEX_GlobalToNaturalEnd));
    112:   PetscCall(PetscLogEventRegister("DMPlexNToGBegin", DM_CLASSID, &DMPLEX_NaturalToGlobalBegin));
    113:   PetscCall(PetscLogEventRegister("DMPlexNToGEnd", DM_CLASSID, &DMPLEX_NaturalToGlobalEnd));
    114:   PetscCall(PetscLogEventRegister("DMPlexStratify", DM_CLASSID, &DMPLEX_Stratify));
    115:   PetscCall(PetscLogEventRegister("DMPlexSymmetrize", DM_CLASSID, &DMPLEX_Symmetrize));
    116:   PetscCall(PetscLogEventRegister("DMPlexPrealloc", DM_CLASSID, &DMPLEX_Preallocate));
    117:   PetscCall(PetscLogEventRegister("DMPlexResidualFE", DM_CLASSID, &DMPLEX_ResidualFEM));
    118:   PetscCall(PetscLogEventRegister("DMPlexJacobianFE", DM_CLASSID, &DMPLEX_JacobianFEM));
    119:   PetscCall(PetscLogEventRegister("DMPlexInterpFE", DM_CLASSID, &DMPLEX_InterpolatorFEM));
    120:   PetscCall(PetscLogEventRegister("DMPlexInjectorFE", DM_CLASSID, &DMPLEX_InjectorFEM));
    121:   PetscCall(PetscLogEventRegister("DMPlexIntegralFE", DM_CLASSID, &DMPLEX_IntegralFEM));
    122:   PetscCall(PetscLogEventRegister("DMPlexRebalance", DM_CLASSID, &DMPLEX_RebalanceSharedPoints));
    123:   PetscCall(PetscLogEventRegister("DMPlexLocatePoints", DM_CLASSID, &DMPLEX_LocatePoints));
    124:   PetscCall(PetscLogEventRegister("DMPlexTopologyView", DM_CLASSID, &DMPLEX_TopologyView));
    125:   PetscCall(PetscLogEventRegister("DMPlexLabelsView", DM_CLASSID, &DMPLEX_LabelsView));
    126:   PetscCall(PetscLogEventRegister("DMPlexCoordinatesView", DM_CLASSID, &DMPLEX_CoordinatesView));
    127:   PetscCall(PetscLogEventRegister("DMPlexSectionView", DM_CLASSID, &DMPLEX_SectionView));
    128:   PetscCall(PetscLogEventRegister("DMPlexGlobalVectorView", DM_CLASSID, &DMPLEX_GlobalVectorView));
    129:   PetscCall(PetscLogEventRegister("DMPlexLocalVectorView", DM_CLASSID, &DMPLEX_LocalVectorView));
    130:   PetscCall(PetscLogEventRegister("DMPlexTopologyLoad", DM_CLASSID, &DMPLEX_TopologyLoad));
    131: #if defined(PETSC_HAVE_HDF5)
    132:   PetscCall(PetscLogEventRegister("DMPlexDistributionView", DM_CLASSID, &DMPLEX_DistributionView));
    133:   PetscCall(PetscLogEventRegister("DMPlexDistributionLoad", DM_CLASSID, &DMPLEX_DistributionLoad));
    134: #endif
    135:   PetscCall(PetscLogEventRegister("DMPlexLabelsLoad", DM_CLASSID, &DMPLEX_LabelsLoad));
    136:   PetscCall(PetscLogEventRegister("DMPlexCoordinatesLoad", DM_CLASSID, &DMPLEX_CoordinatesLoad));
    137:   PetscCall(PetscLogEventRegister("DMPlexSectionLoad", DM_CLASSID, &DMPLEX_SectionLoad));
    138:   PetscCall(PetscLogEventRegister("DMPlexGlobalVectorLoad", DM_CLASSID, &DMPLEX_GlobalVectorLoad));
    139:   PetscCall(PetscLogEventRegister("DMPlexLocalVectorLoad", DM_CLASSID, &DMPLEX_LocalVectorLoad));
    140:   PetscCall(PetscLogEventRegister("DMPlexMetricEnforceSPD", DM_CLASSID, &DMPLEX_MetricEnforceSPD));
    141:   PetscCall(PetscLogEventRegister("DMPlexMetricNormalize", DM_CLASSID, &DMPLEX_MetricNormalize));
    142:   PetscCall(PetscLogEventRegister("DMPlexMetricAverage", DM_CLASSID, &DMPLEX_MetricAverage));
    143:   PetscCall(PetscLogEventRegister("DMPlexMetricIntersect", DM_CLASSID, &DMPLEX_MetricIntersection));
    144:   PetscCall(PetscLogEventRegister("DMPlexGenerate", DM_CLASSID, &DMPLEX_Generate));
    145:   PetscCall(PetscLogEventRegister("DMPlexTransform", DM_CLASSID, &DMPLEX_Transform));
    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("DMSwarmMigrate", DM_CLASSID, &DMSWARM_Migrate));
    156:   PetscCall(PetscLogEventRegister("DMSwarmDETSetup", DM_CLASSID, &DMSWARM_DataExchangerTopologySetup));
    157:   PetscCall(PetscLogEventRegister("DMSwarmDExBegin", DM_CLASSID, &DMSWARM_DataExchangerBegin));
    158:   PetscCall(PetscLogEventRegister("DMSwarmDExEnd", DM_CLASSID, &DMSWARM_DataExchangerEnd));
    159:   PetscCall(PetscLogEventRegister("DMSwarmDESendCnt", DM_CLASSID, &DMSWARM_DataExchangerSendCount));
    160:   PetscCall(PetscLogEventRegister("DMSwarmDEPack", DM_CLASSID, &DMSWARM_DataExchangerPack));
    161:   PetscCall(PetscLogEventRegister("DMSwarmAddPnts", DM_CLASSID, &DMSWARM_AddPoints));
    162:   PetscCall(PetscLogEventRegister("DMSwarmRmvPnts", DM_CLASSID, &DMSWARM_RemovePoints));
    163:   PetscCall(PetscLogEventRegister("DMSwarmSort", DM_CLASSID, &DMSWARM_Sort));
    164:   PetscCall(PetscLogEventRegister("DMSwarmSetSizes", DM_CLASSID, &DMSWARM_SetSizes));

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

    173:     classids[0] = DM_CLASSID;
    174:     PetscCall(PetscInfoProcessClass("dm", 1, classids));
    175:   }

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

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

    197: static PetscBool PetscFEPackageInitialized = PETSC_FALSE;

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

    203:   Level: developer

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

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

    225:   Level: developer

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

    234:   PetscFunctionBegin;
    235:   if (PetscFEPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    236:   PetscFEPackageInitialized = PETSC_TRUE;

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

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

    272: static PetscBool PetscFVPackageInitialized = PETSC_FALSE;

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

    278:   Level: developer

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

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

    298:   Level: developer

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

    307:   PetscFunctionBegin;
    308:   if (PetscFVPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    309:   PetscFVPackageInitialized = PETSC_TRUE;

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

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

    340: static PetscBool PetscDSPackageInitialized = PETSC_FALSE;

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

    346:   Level: developer

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

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

    364:   Level: developer

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

    373:   PetscFunctionBegin;
    374:   if (PetscDSPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
    375:   PetscDSPackageInitialized = PETSC_TRUE;

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

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

    401: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
    402: /*
    403:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

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

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

    422: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */