xref: /petsc/src/dm/interface/dlregisdmdm.c (revision 6528b96d098a3a0d8b5eec2f1c205a3c25c0d721)
1e8597998SBarry Smith 
24b5b0a90SBarry Smith #include <petscao.h>
35fdea053SToby Isaac #include <petsc/private/dmlabelimpl.h>
43da551e6SToby Isaac #include <petsc/private/dmfieldimpl.h>
5af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h>
6af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h>
7af0996ceSBarry Smith #include <petsc/private/petscfeimpl.h>
8af0996ceSBarry Smith #include <petsc/private/petscfvimpl.h>
9ed923d71SDave May #include <petsc/private/dmswarmimpl.h>
10e8597998SBarry Smith 
11e8597998SBarry Smith static PetscBool DMPackageInitialized = PETSC_FALSE;
12e8597998SBarry Smith /*@C
13e8597998SBarry Smith   DMFinalizePackage - This function finalizes everything in the DM package. It is called
14e8597998SBarry Smith   from PetscFinalize().
15e8597998SBarry Smith 
16e8597998SBarry Smith   Level: developer
17e8597998SBarry Smith 
18e8597998SBarry Smith .seealso: PetscInitialize()
19e8597998SBarry Smith @*/
20e8597998SBarry Smith PetscErrorCode  DMFinalizePackage(void)
21e8597998SBarry Smith {
22e8597998SBarry Smith   PetscErrorCode ierr;
23e8597998SBarry Smith 
24e8597998SBarry Smith   PetscFunctionBegin;
2537e93019SBarry Smith   ierr = PetscFunctionListDestroy(&DMList);CHKERRQ(ierr);
26e8597998SBarry Smith   DMPackageInitialized = PETSC_FALSE;
27e8597998SBarry Smith   DMRegisterAllCalled  = PETSC_FALSE;
28e8597998SBarry Smith   PetscFunctionReturn(0);
29e8597998SBarry Smith }
30e8597998SBarry Smith 
31e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
328cc058d9SJed Brown PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat);
3361710fbeSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreate_HYPRESStruct(Mat);
34e8597998SBarry Smith #endif
35e8597998SBarry Smith 
36e8597998SBarry Smith /*@C
37e8597998SBarry Smith   DMInitializePackage - This function initializes everything in the DM package. It is called
388a690491SBarry Smith   from PetscDLLibraryRegister_petscdm() when using dynamic libraries, and on the first call to AOCreate()
398a690491SBarry Smith   or DMDACreate() when using shared or static libraries.
40e8597998SBarry Smith 
41e8597998SBarry Smith   Level: developer
42e8597998SBarry Smith 
43e8597998SBarry Smith .seealso: PetscInitialize()
44e8597998SBarry Smith @*/
45607a6623SBarry Smith PetscErrorCode  DMInitializePackage(void)
46e8597998SBarry Smith {
47e8597998SBarry Smith   char           logList[256];
488e81d068SLisandro Dalcin   PetscBool      opt,pkg;
49e8597998SBarry Smith   PetscErrorCode ierr;
50e8597998SBarry Smith 
51e8597998SBarry Smith   PetscFunctionBegin;
52e8597998SBarry Smith   if (DMPackageInitialized) PetscFunctionReturn(0);
53e8597998SBarry Smith   DMPackageInitialized = PETSC_TRUE;
54e8597998SBarry Smith 
55e8597998SBarry Smith   /* Register Classes */
56e8597998SBarry Smith   ierr = PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);CHKERRQ(ierr);
57d67d17b1SMatthew G. Knepley   ierr = PetscClassIdRegister("DM Label",&DMLABEL_CLASSID);CHKERRQ(ierr);
582cd22861SMatthew G. Knepley   ierr = PetscClassIdRegister("Quadrature",&PETSCQUADRATURE_CLASSID);CHKERRQ(ierr);
59e8597998SBarry Smith 
60e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
61bdf89e91SBarry Smith   ierr = MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);CHKERRQ(ierr);
6261710fbeSStefano Zampini   ierr = MatRegister(MATHYPRESSTRUCT, MatCreate_HYPRESStruct);CHKERRQ(ierr);
63e8597998SBarry Smith #endif
645fdea053SToby Isaac   ierr = PetscSectionSymRegister(PETSCSECTIONSYMLABEL,PetscSectionSymCreate_Label);CHKERRQ(ierr);
65e8597998SBarry Smith 
66e8597998SBarry Smith   /* Register Constructors */
67607a6623SBarry Smith   ierr = DMRegisterAll();CHKERRQ(ierr);
68e8597998SBarry Smith   /* Register Events */
69e8597998SBarry Smith   ierr = PetscLogEventRegister("DMConvert",              DM_CLASSID,&DM_Convert);CHKERRQ(ierr);
70e8597998SBarry Smith   ierr = PetscLogEventRegister("DMGlobalToLocal",        DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr);
71e8597998SBarry Smith   ierr = PetscLogEventRegister("DMLocalToGlobal",        DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr);
7247a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMLocatePoints",         DM_CLASSID,&DM_LocatePoints);CHKERRQ(ierr);
7347a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMCoarsen",              DM_CLASSID,&DM_Coarsen);CHKERRQ(ierr);
7442ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateInterp",         DM_CLASSID,&DM_CreateInterpolation);CHKERRQ(ierr);
7542ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateRestrict",       DM_CLASSID,&DM_CreateRestriction);CHKERRQ(ierr);
765a84ad33SLisandro Dalcin   ierr = PetscLogEventRegister("DMCreateInject",         DM_CLASSID,&DM_CreateInjection);CHKERRQ(ierr);
77fdc842d1SBarry Smith   ierr = PetscLogEventRegister("DMCreateMat",            DM_CLASSID,&DM_CreateMatrix);CHKERRQ(ierr);
7858cd63d5SVaclav Hapla   ierr = PetscLogEventRegister("DMLoad",                 DM_CLASSID,&DM_Load);CHKERRQ(ierr);
79557cf195SMatthew G. Knepley   ierr = PetscLogEventRegister("DMAdaptInterp",          DM_CLASSID,&DM_AdaptInterpolator);CHKERRQ(ierr);
80e8597998SBarry Smith 
81b09969d6SVaclav Hapla   ierr = PetscLogEventRegister("DMPlexBuFrCeLi",         DM_CLASSID,&DMPLEX_BuildFromCellList);CHKERRQ(ierr);
82b09969d6SVaclav Hapla   ierr = PetscLogEventRegister("DMPlexBuCoFrCeLi",       DM_CLASSID,&DMPLEX_BuildCoordinatesFromCellList);CHKERRQ(ierr);
83f1f45c63SVaclav Hapla   ierr = PetscLogEventRegister("DMPlexCreateGmsh",       DM_CLASSID,&DMPLEX_CreateGmsh);CHKERRQ(ierr);
84f1f45c63SVaclav Hapla   ierr = PetscLogEventRegister("DMPlexCrFromFile",       DM_CLASSID,&DMPLEX_CreateFromFile);CHKERRQ(ierr);
8567eb269bSLisandro Dalcin   ierr = PetscLogEventRegister("Mesh Partition",         DM_CLASSID,&DMPLEX_Partition);CHKERRQ(ierr);
861b858b30SMichael Lange   ierr = PetscLogEventRegister("Mesh Migration",         DM_CLASSID,&DMPLEX_Migrate);CHKERRQ(ierr);
8730b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartSelf",         DM_CLASSID,&DMPLEX_PartSelf);CHKERRQ(ierr);
8830b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartLblInv",       DM_CLASSID,&DMPLEX_PartLabelInvert);CHKERRQ(ierr);
8930b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartLblSF",        DM_CLASSID,&DMPLEX_PartLabelCreateSF);CHKERRQ(ierr);
9030b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartStrtSF",       DM_CLASSID,&DMPLEX_PartStratSF);CHKERRQ(ierr);
9130b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPointSF",          DM_CLASSID,&DMPLEX_CreatePointSF);CHKERRQ(ierr);
9275a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterp",           DM_CLASSID,&DMPLEX_Interpolate);CHKERRQ(ierr);
93e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexDistribute",       DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr);
9475a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistCones",        DM_CLASSID,&DMPLEX_DistributeCones);CHKERRQ(ierr);
9575a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistLabels",       DM_CLASSID,&DMPLEX_DistributeLabels);CHKERRQ(ierr);
9665694654SLisandro Dalcin   ierr = PetscLogEventRegister("DMPlexDistSF",           DM_CLASSID,&DMPLEX_DistributeSF);CHKERRQ(ierr);
9765694654SLisandro Dalcin   ierr = PetscLogEventRegister("DMPlexDistOvrlp",        DM_CLASSID,&DMPLEX_DistributeOverlap);CHKERRQ(ierr);
9875a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistField",        DM_CLASSID,&DMPLEX_DistributeField);CHKERRQ(ierr);
9975a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistData",         DM_CLASSID,&DMPLEX_DistributeData);CHKERRQ(ierr);
10025afeb17SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpSF",         DM_CLASSID,&DMPLEX_InterpolateSF);CHKERRQ(ierr);
101fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNBegin",        DM_CLASSID,&DMPLEX_GlobalToNaturalBegin);CHKERRQ(ierr);
102fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNEnd",          DM_CLASSID,&DMPLEX_GlobalToNaturalEnd);CHKERRQ(ierr);
103fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGBegin",        DM_CLASSID,&DMPLEX_NaturalToGlobalBegin);CHKERRQ(ierr);
104fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGEnd",          DM_CLASSID,&DMPLEX_NaturalToGlobalEnd);CHKERRQ(ierr);
105e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexStratify",         DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr);
10630b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexSymmetrize",       DM_CLASSID,&DMPLEX_Symmetrize);CHKERRQ(ierr);
10775a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexPrealloc",         DM_CLASSID,&DMPLEX_Preallocate);CHKERRQ(ierr);
10875a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexResidualFE",       DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr);
10975a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexJacobianFE",       DM_CLASSID,&DMPLEX_JacobianFEM);CHKERRQ(ierr);
11075a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpFE",         DM_CLASSID,&DMPLEX_InterpolatorFEM);CHKERRQ(ierr);
11175a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInjectorFE",       DM_CLASSID,&DMPLEX_InjectorFEM);CHKERRQ(ierr);
112c1f031eeSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexIntegralFEM",      DM_CLASSID,&DMPLEX_IntegralFEM);CHKERRQ(ierr);
11330b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexRebalance",        DM_CLASSID,&DMPLEX_RebalanceSharedPoints);CHKERRQ(ierr);
114cadf77a0SMark Adams   ierr = PetscLogEventRegister("DMPlexLocatePoints",     DM_CLASSID,&DMPLEX_LocatePoints);CHKERRQ(ierr);
115ed923d71SDave May 
116ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmMigrate",         DM_CLASSID,&DMSWARM_Migrate);CHKERRQ(ierr);
117ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDETSetup",        DM_CLASSID,&DMSWARM_DataExchangerTopologySetup);CHKERRQ(ierr);
118ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDExBegin",        DM_CLASSID,&DMSWARM_DataExchangerBegin);CHKERRQ(ierr);
119ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDExEnd",          DM_CLASSID,&DMSWARM_DataExchangerEnd);CHKERRQ(ierr);
120ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDESendCnt",       DM_CLASSID,&DMSWARM_DataExchangerSendCount);CHKERRQ(ierr);
121ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDEPack",          DM_CLASSID,&DMSWARM_DataExchangerPack);CHKERRQ(ierr);
122f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmAddPnts",         DM_CLASSID,&DMSWARM_AddPoints);CHKERRQ(ierr);
123f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmRmvPnts",         DM_CLASSID,&DMSWARM_RemovePoints);CHKERRQ(ierr);
124f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmSort",            DM_CLASSID,&DMSWARM_Sort);CHKERRQ(ierr);
125f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmSetSizes",        DM_CLASSID,&DMSWARM_SetSizes);CHKERRQ(ierr);
126e94e781bSJacob Faibussowitsch   /* Process Info */
127e94e781bSJacob Faibussowitsch   {
128e94e781bSJacob Faibussowitsch     PetscClassId  classids[1];
129ed923d71SDave May 
130e94e781bSJacob Faibussowitsch     classids[0] = DM_CLASSID;
131e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("dm", 1, classids);CHKERRQ(ierr);
132e8597998SBarry Smith   }
1338e81d068SLisandro Dalcin 
134e8597998SBarry Smith   /* Process summary exclusions */
1358e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
136e8597998SBarry Smith   if (opt) {
1378e81d068SLisandro Dalcin     ierr = PetscStrInList("dm",logList,',',&pkg);CHKERRQ(ierr);
138fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(DM_CLASSID);CHKERRQ(ierr);}
139e8597998SBarry Smith   }
1408e81d068SLisandro Dalcin 
1413a074057SBarry Smith   ierr = DMPlexGenerateRegisterAll();CHKERRQ(ierr);
1423a074057SBarry Smith   ierr = PetscRegisterFinalize(DMPlexGenerateRegisterDestroy);CHKERRQ(ierr);
143e8597998SBarry Smith   ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr);
144e8597998SBarry Smith   PetscFunctionReturn(0);
145e8597998SBarry Smith }
14606759e06SMatthew G. Knepley #include <petscfe.h>
147e8597998SBarry Smith 
14806759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE;
14906759e06SMatthew G. Knepley /*@C
15006759e06SMatthew G. Knepley   PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called
15106759e06SMatthew G. Knepley   from PetscFinalize().
152e8597998SBarry Smith 
15306759e06SMatthew G. Knepley   Level: developer
15406759e06SMatthew G. Knepley 
15506759e06SMatthew G. Knepley .seealso: PetscInitialize()
15606759e06SMatthew G. Knepley @*/
15706759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void)
15806759e06SMatthew G. Knepley {
15906759e06SMatthew G. Knepley   PetscErrorCode ierr;
16006759e06SMatthew G. Knepley 
16106759e06SMatthew G. Knepley   PetscFunctionBegin;
16206759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr);
16306759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr);
1640483ade4SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFEList);CHKERRQ(ierr);
16506759e06SMatthew G. Knepley   PetscFEPackageInitialized       = PETSC_FALSE;
16606759e06SMatthew G. Knepley   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
16706759e06SMatthew G. Knepley   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
1680483ade4SMatthew G. Knepley   PetscFERegisterAllCalled        = PETSC_FALSE;
16906759e06SMatthew G. Knepley   PetscFunctionReturn(0);
17006759e06SMatthew G. Knepley }
17106759e06SMatthew G. Knepley 
17206759e06SMatthew G. Knepley /*@C
17306759e06SMatthew G. Knepley   PetscFEInitializePackage - This function initializes everything in the FE package. It is called
17406759e06SMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate()
17506759e06SMatthew G. Knepley   when using static libraries.
17606759e06SMatthew G. Knepley 
17706759e06SMatthew G. Knepley   Level: developer
17806759e06SMatthew G. Knepley 
17906759e06SMatthew G. Knepley .seealso: PetscInitialize()
18006759e06SMatthew G. Knepley @*/
18106759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void)
18206759e06SMatthew G. Knepley {
18306759e06SMatthew G. Knepley   char           logList[256];
1848e81d068SLisandro Dalcin   PetscBool      opt,pkg;
18506759e06SMatthew G. Knepley   PetscErrorCode ierr;
18606759e06SMatthew G. Knepley 
18706759e06SMatthew G. Knepley   PetscFunctionBegin;
18806759e06SMatthew G. Knepley   if (PetscFEPackageInitialized) PetscFunctionReturn(0);
18906759e06SMatthew G. Knepley   PetscFEPackageInitialized = PETSC_TRUE;
19006759e06SMatthew G. Knepley 
19106759e06SMatthew G. Knepley   /* Register Classes */
19206759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr);
19306759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Dual Space",   &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr);
19406759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("FE Space",     &PETSCFE_CLASSID);CHKERRQ(ierr);
19506759e06SMatthew G. Knepley   /* Register Constructors */
19606759e06SMatthew G. Knepley   ierr = PetscSpaceRegisterAll();CHKERRQ(ierr);
1970483ade4SMatthew G. Knepley   ierr = PetscDualSpaceRegisterAll();CHKERRQ(ierr);
1980483ade4SMatthew G. Knepley   ierr = PetscFERegisterAll();CHKERRQ(ierr);
19906759e06SMatthew G. Knepley   /* Register Events */
200ead873ccSMatthew G. Knepley   ierr = PetscLogEventRegister("DualSpaceSetUp", PETSCDUALSPACE_CLASSID, &PETSCDUALSPACE_SetUp);CHKERRQ(ierr);
201ead873ccSMatthew G. Knepley   ierr = PetscLogEventRegister("FESetUp",        PETSCFE_CLASSID,        &PETSCFE_SetUp);CHKERRQ(ierr);
202e94e781bSJacob Faibussowitsch   /* Process Info */
203e94e781bSJacob Faibussowitsch   {
204e94e781bSJacob Faibussowitsch     PetscClassId  classids[3];
205e94e781bSJacob Faibussowitsch 
206e94e781bSJacob Faibussowitsch     classids[0] = PETSCFE_CLASSID;
207e94e781bSJacob Faibussowitsch     classids[1] = PETSCSPACE_CLASSID;
208e94e781bSJacob Faibussowitsch     classids[2] = PETSCDUALSPACE_CLASSID;
209e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("fe", 1, classids);CHKERRQ(ierr);
210e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("space", 1, &classids[1]);CHKERRQ(ierr);
211e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("dualspace", 1, &classids[2]);CHKERRQ(ierr);
21206759e06SMatthew G. Knepley   }
21306759e06SMatthew G. Knepley   /* Process summary exclusions */
2148e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
21506759e06SMatthew G. Knepley   if (opt) {
2168e81d068SLisandro Dalcin     ierr = PetscStrInList("fe",logList,',',&pkg);CHKERRQ(ierr);
217fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
21806759e06SMatthew G. Knepley   }
2198e81d068SLisandro Dalcin   /* Register package finalizer */
22006759e06SMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr);
22106759e06SMatthew G. Knepley   PetscFunctionReturn(0);
22206759e06SMatthew G. Knepley }
223f62f30faSMatthew G. Knepley #include <petscfv.h>
224f62f30faSMatthew G. Knepley 
225f62f30faSMatthew G. Knepley static PetscBool PetscFVPackageInitialized = PETSC_FALSE;
226f62f30faSMatthew G. Knepley /*@C
227f62f30faSMatthew G. Knepley   PetscFVFinalizePackage - This function finalizes everything in the PetscFV package. It is called
228f62f30faSMatthew G. Knepley   from PetscFinalize().
229f62f30faSMatthew G. Knepley 
230f62f30faSMatthew G. Knepley   Level: developer
231f62f30faSMatthew G. Knepley 
232f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
233f62f30faSMatthew G. Knepley @*/
234f62f30faSMatthew G. Knepley PetscErrorCode PetscFVFinalizePackage(void)
235f62f30faSMatthew G. Knepley {
236f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
237f62f30faSMatthew G. Knepley 
238f62f30faSMatthew G. Knepley   PetscFunctionBegin;
239ab2453f0SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscLimiterList);CHKERRQ(ierr);
240f62f30faSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFVList);CHKERRQ(ierr);
241f62f30faSMatthew G. Knepley   PetscFVPackageInitialized     = PETSC_FALSE;
242f62f30faSMatthew G. Knepley   PetscFVRegisterAllCalled      = PETSC_FALSE;
243ab2453f0SMatthew G. Knepley   PetscLimiterRegisterAllCalled = PETSC_FALSE;
244f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
245f62f30faSMatthew G. Knepley }
246f62f30faSMatthew G. Knepley 
247f62f30faSMatthew G. Knepley /*@C
248f62f30faSMatthew G. Knepley   PetscFVInitializePackage - This function initializes everything in the FV package. It is called
249f62f30faSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscFVCreate()
250f62f30faSMatthew G. Knepley   when using static libraries.
251f62f30faSMatthew G. Knepley 
252f62f30faSMatthew G. Knepley   Level: developer
253f62f30faSMatthew G. Knepley 
254f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
255f62f30faSMatthew G. Knepley @*/
256f62f30faSMatthew G. Knepley PetscErrorCode PetscFVInitializePackage(void)
257f62f30faSMatthew G. Knepley {
258f62f30faSMatthew G. Knepley   char           logList[256];
2598e81d068SLisandro Dalcin   PetscBool      opt,pkg;
260f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
261f62f30faSMatthew G. Knepley 
262f62f30faSMatthew G. Knepley   PetscFunctionBegin;
263f62f30faSMatthew G. Knepley   if (PetscFVPackageInitialized) PetscFunctionReturn(0);
264f62f30faSMatthew G. Knepley   PetscFVPackageInitialized = PETSC_TRUE;
265f62f30faSMatthew G. Knepley 
266f62f30faSMatthew G. Knepley   /* Register Classes */
267f62f30faSMatthew G. Knepley   ierr = PetscClassIdRegister("FV Space", &PETSCFV_CLASSID);CHKERRQ(ierr);
268ab2453f0SMatthew G. Knepley   ierr = PetscClassIdRegister("Limiter",  &PETSCLIMITER_CLASSID);CHKERRQ(ierr);
269f62f30faSMatthew G. Knepley   /* Register Constructors */
270f62f30faSMatthew G. Knepley   ierr = PetscFVRegisterAll();CHKERRQ(ierr);
271f62f30faSMatthew G. Knepley   /* Register Events */
272e94e781bSJacob Faibussowitsch   /* Process Info */
273e94e781bSJacob Faibussowitsch   {
274e94e781bSJacob Faibussowitsch     PetscClassId  classids[2];
275e94e781bSJacob Faibussowitsch 
276e94e781bSJacob Faibussowitsch     classids[0] = PETSCFV_CLASSID;
277e94e781bSJacob Faibussowitsch     classids[1] = PETSCLIMITER_CLASSID;
278e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("fv", 1, classids);CHKERRQ(ierr);
279e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("limiter", 1, &classids[1]);CHKERRQ(ierr);
280f62f30faSMatthew G. Knepley   }
281f62f30faSMatthew G. Knepley   /* Process summary exclusions */
2828e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
283f62f30faSMatthew G. Knepley   if (opt) {
2848e81d068SLisandro Dalcin     ierr = PetscStrInList("fv",logList,',',&pkg);CHKERRQ(ierr);
285fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
2868e81d068SLisandro Dalcin     ierr = PetscStrInList("limiter",logList,',',&pkg);CHKERRQ(ierr);
287fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCLIMITER_CLASSID);CHKERRQ(ierr);}
288f62f30faSMatthew G. Knepley   }
2898e81d068SLisandro Dalcin   /* Register package finalizer */
290f62f30faSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFVFinalizePackage);CHKERRQ(ierr);
291f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
292f62f30faSMatthew G. Knepley }
2932764a2aaSMatthew G. Knepley #include <petscds.h>
294022a7a5cSMatthew G. Knepley 
2952764a2aaSMatthew G. Knepley static PetscBool PetscDSPackageInitialized = PETSC_FALSE;
296022a7a5cSMatthew G. Knepley /*@C
2972764a2aaSMatthew G. Knepley   PetscDSFinalizePackage - This function finalizes everything in the PetscDS package. It is called
298022a7a5cSMatthew G. Knepley   from PetscFinalize().
299022a7a5cSMatthew G. Knepley 
300022a7a5cSMatthew G. Knepley   Level: developer
301022a7a5cSMatthew G. Knepley 
302022a7a5cSMatthew G. Knepley .seealso: PetscInitialize()
303022a7a5cSMatthew G. Knepley @*/
3042764a2aaSMatthew G. Knepley PetscErrorCode PetscDSFinalizePackage(void)
305022a7a5cSMatthew G. Knepley {
306022a7a5cSMatthew G. Knepley   PetscErrorCode ierr;
307022a7a5cSMatthew G. Knepley 
308022a7a5cSMatthew G. Knepley   PetscFunctionBegin;
3092764a2aaSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDSList);CHKERRQ(ierr);
3102764a2aaSMatthew G. Knepley   PetscDSPackageInitialized = PETSC_FALSE;
3112764a2aaSMatthew G. Knepley   PetscDSRegisterAllCalled  = PETSC_FALSE;
312022a7a5cSMatthew G. Knepley   PetscFunctionReturn(0);
313022a7a5cSMatthew G. Knepley }
314022a7a5cSMatthew G. Knepley 
315022a7a5cSMatthew G. Knepley /*@C
3162764a2aaSMatthew G. Knepley   PetscDSInitializePackage - This function initializes everything in the DS package. It is called
3172764a2aaSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscDSCreate()
318022a7a5cSMatthew G. Knepley   when using static libraries.
319022a7a5cSMatthew G. Knepley 
320022a7a5cSMatthew G. Knepley   Level: developer
321022a7a5cSMatthew G. Knepley 
322022a7a5cSMatthew G. Knepley .seealso: PetscInitialize()
323022a7a5cSMatthew G. Knepley @*/
3242764a2aaSMatthew G. Knepley PetscErrorCode PetscDSInitializePackage(void)
325022a7a5cSMatthew G. Knepley {
326022a7a5cSMatthew G. Knepley   char           logList[256];
3278e81d068SLisandro Dalcin   PetscBool      opt,pkg;
328022a7a5cSMatthew G. Knepley   PetscErrorCode ierr;
329022a7a5cSMatthew G. Knepley 
330022a7a5cSMatthew G. Knepley   PetscFunctionBegin;
3312764a2aaSMatthew G. Knepley   if (PetscDSPackageInitialized) PetscFunctionReturn(0);
3322764a2aaSMatthew G. Knepley   PetscDSPackageInitialized = PETSC_TRUE;
333022a7a5cSMatthew G. Knepley 
334022a7a5cSMatthew G. Knepley   /* Register Classes */
3352764a2aaSMatthew G. Knepley   ierr = PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID);CHKERRQ(ierr);
336*6528b96dSMatthew G. Knepley   ierr = PetscClassIdRegister("Weak Form",       &PETSCWEAKFORM_CLASSID);CHKERRQ(ierr);
337022a7a5cSMatthew G. Knepley   /* Register Constructors */
3382764a2aaSMatthew G. Knepley   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
339022a7a5cSMatthew G. Knepley   /* Register Events */
340e94e781bSJacob Faibussowitsch   /* Process Info */
341e94e781bSJacob Faibussowitsch   {
342e94e781bSJacob Faibussowitsch     PetscClassId  classids[1];
343e94e781bSJacob Faibussowitsch 
344e94e781bSJacob Faibussowitsch     classids[0] = PETSCDS_CLASSID;
345e94e781bSJacob Faibussowitsch     ierr = PetscInfoProcessClass("ds", 1, classids);CHKERRQ(ierr);
346022a7a5cSMatthew G. Knepley   }
347022a7a5cSMatthew G. Knepley   /* Process summary exclusions */
3488e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
349022a7a5cSMatthew G. Knepley   if (opt) {
3508e81d068SLisandro Dalcin     ierr = PetscStrInList("ds",logList,',',&pkg);CHKERRQ(ierr);
351fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCDS_CLASSID);CHKERRQ(ierr);}
352022a7a5cSMatthew G. Knepley   }
3538e81d068SLisandro Dalcin   /* Register package finalizer */
3542764a2aaSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscDSFinalizePackage);CHKERRQ(ierr);
355022a7a5cSMatthew G. Knepley   PetscFunctionReturn(0);
356022a7a5cSMatthew G. Knepley }
357e8597998SBarry Smith 
358aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
359e8597998SBarry Smith /*
360e8597998SBarry Smith   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
361e8597998SBarry Smith 
362e8597998SBarry Smith   This one registers all the mesh generators and partitioners that are in
363e8597998SBarry Smith   the basic DM library.
364e8597998SBarry Smith 
365e8597998SBarry Smith */
366607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
367e8597998SBarry Smith {
368e8597998SBarry Smith   PetscErrorCode ierr;
369e8597998SBarry Smith 
370e8597998SBarry Smith   PetscFunctionBegin;
371607a6623SBarry Smith   ierr = AOInitializePackage();CHKERRQ(ierr);
372abe9303eSLisandro Dalcin   ierr = PetscPartitionerInitializePackage();CHKERRQ(ierr);
373607a6623SBarry Smith   ierr = DMInitializePackage();CHKERRQ(ierr);
37406759e06SMatthew G. Knepley   ierr = PetscFEInitializePackage();CHKERRQ(ierr);
375ab2453f0SMatthew G. Knepley   ierr = PetscFVInitializePackage();CHKERRQ(ierr);
3763da551e6SToby Isaac   ierr = DMFieldInitializePackage();CHKERRQ(ierr);
377e8597998SBarry Smith   PetscFunctionReturn(0);
378e8597998SBarry Smith }
379e8597998SBarry Smith 
380aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */
381