xref: /petsc/src/dm/interface/dlregisdmdm.c (revision 5a84ad33814bf43cbf4616f6fbb16f87c523bdea)
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;
2577623264SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscPartitionerList);CHKERRQ(ierr);
2637e93019SBarry Smith   ierr = PetscFunctionListDestroy(&DMList);CHKERRQ(ierr);
27e8597998SBarry Smith   DMPackageInitialized = PETSC_FALSE;
28e8597998SBarry Smith   DMRegisterAllCalled  = PETSC_FALSE;
2977623264SMatthew G. Knepley   PetscPartitionerRegisterAllCalled = PETSC_FALSE;
30e8597998SBarry Smith   PetscFunctionReturn(0);
31e8597998SBarry Smith }
32e8597998SBarry Smith 
33e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
348cc058d9SJed Brown PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat);
3561710fbeSStefano Zampini PETSC_EXTERN PetscErrorCode MatCreate_HYPRESStruct(Mat);
36e8597998SBarry Smith #endif
37e8597998SBarry Smith 
38e8597998SBarry Smith /*@C
39e8597998SBarry Smith   DMInitializePackage - This function initializes everything in the DM package. It is called
408a690491SBarry Smith   from PetscDLLibraryRegister_petscdm() when using dynamic libraries, and on the first call to AOCreate()
418a690491SBarry Smith   or DMDACreate() when using shared or static libraries.
42e8597998SBarry Smith 
43e8597998SBarry Smith   Level: developer
44e8597998SBarry Smith 
45e8597998SBarry Smith .seealso: PetscInitialize()
46e8597998SBarry Smith @*/
47607a6623SBarry Smith PetscErrorCode  DMInitializePackage(void)
48e8597998SBarry Smith {
49e8597998SBarry Smith   char           logList[256];
508e81d068SLisandro Dalcin   PetscBool      opt,pkg;
51e8597998SBarry Smith   PetscErrorCode ierr;
52e8597998SBarry Smith 
53e8597998SBarry Smith   PetscFunctionBegin;
54e8597998SBarry Smith   if (DMPackageInitialized) PetscFunctionReturn(0);
55e8597998SBarry Smith   DMPackageInitialized = PETSC_TRUE;
56e8597998SBarry Smith 
57e8597998SBarry Smith   /* Register Classes */
58e8597998SBarry Smith   ierr = PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);CHKERRQ(ierr);
59d67d17b1SMatthew G. Knepley   ierr = PetscClassIdRegister("DM Label",&DMLABEL_CLASSID);CHKERRQ(ierr);
6077623264SMatthew G. Knepley   ierr = PetscClassIdRegister("GraphPartitioner",&PETSCPARTITIONER_CLASSID);CHKERRQ(ierr);
61e8597998SBarry Smith 
62e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
63bdf89e91SBarry Smith   ierr = MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);CHKERRQ(ierr);
6461710fbeSStefano Zampini   ierr = MatRegister(MATHYPRESSTRUCT, MatCreate_HYPRESStruct);CHKERRQ(ierr);
65e8597998SBarry Smith #endif
665fdea053SToby Isaac   ierr = PetscSectionSymRegister(PETSCSECTIONSYMLABEL,PetscSectionSymCreate_Label);CHKERRQ(ierr);
67e8597998SBarry Smith 
68e8597998SBarry Smith   /* Register Constructors */
69607a6623SBarry Smith   ierr = DMRegisterAll();CHKERRQ(ierr);
70e8597998SBarry Smith   /* Register Events */
71e8597998SBarry Smith   ierr = PetscLogEventRegister("DMConvert",              DM_CLASSID,&DM_Convert);CHKERRQ(ierr);
72e8597998SBarry Smith   ierr = PetscLogEventRegister("DMGlobalToLocal",        DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr);
73e8597998SBarry Smith   ierr = PetscLogEventRegister("DMLocalToGlobal",        DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr);
7447a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMLocatePoints",         DM_CLASSID,&DM_LocatePoints);CHKERRQ(ierr);
7547a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMCoarsen",              DM_CLASSID,&DM_Coarsen);CHKERRQ(ierr);
7642ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateInterp",         DM_CLASSID,&DM_CreateInterpolation);CHKERRQ(ierr);
7742ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateRestrict",       DM_CLASSID,&DM_CreateRestriction);CHKERRQ(ierr);
78*5a84ad33SLisandro Dalcin   ierr = PetscLogEventRegister("DMCreateInject",         DM_CLASSID,&DM_CreateInjection);CHKERRQ(ierr);
79fdc842d1SBarry Smith   ierr = PetscLogEventRegister("DMCreateMat",            DM_CLASSID,&DM_CreateMatrix);CHKERRQ(ierr);
80e8597998SBarry Smith 
8167eb269bSLisandro Dalcin   ierr = PetscLogEventRegister("Mesh Partition",         DM_CLASSID,&DMPLEX_Partition);CHKERRQ(ierr);
821b858b30SMichael Lange   ierr = PetscLogEventRegister("Mesh Migration",         DM_CLASSID,&DMPLEX_Migrate);CHKERRQ(ierr);
8330b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartSelf",         DM_CLASSID,&DMPLEX_PartSelf);CHKERRQ(ierr);
8430b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartLblInv",       DM_CLASSID,&DMPLEX_PartLabelInvert);CHKERRQ(ierr);
8530b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartLblSF",        DM_CLASSID,&DMPLEX_PartLabelCreateSF);CHKERRQ(ierr);
8630b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPartStrtSF",       DM_CLASSID,&DMPLEX_PartStratSF);CHKERRQ(ierr);
8730b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexPointSF",          DM_CLASSID,&DMPLEX_CreatePointSF);CHKERRQ(ierr);
8875a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterp",           DM_CLASSID,&DMPLEX_Interpolate);CHKERRQ(ierr);
89e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexDistribute",       DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr);
9075a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistCones",        DM_CLASSID,&DMPLEX_DistributeCones);CHKERRQ(ierr);
9175a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistLabels",       DM_CLASSID,&DMPLEX_DistributeLabels);CHKERRQ(ierr);
9265694654SLisandro Dalcin   ierr = PetscLogEventRegister("DMPlexDistSF",           DM_CLASSID,&DMPLEX_DistributeSF);CHKERRQ(ierr);
9365694654SLisandro Dalcin   ierr = PetscLogEventRegister("DMPlexDistOvrlp",        DM_CLASSID,&DMPLEX_DistributeOverlap);CHKERRQ(ierr);
9475a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistField",        DM_CLASSID,&DMPLEX_DistributeField);CHKERRQ(ierr);
9575a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistData",         DM_CLASSID,&DMPLEX_DistributeData);CHKERRQ(ierr);
9625afeb17SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpSF",         DM_CLASSID,&DMPLEX_InterpolateSF);CHKERRQ(ierr);
97fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNBegin",        DM_CLASSID,&DMPLEX_GlobalToNaturalBegin);CHKERRQ(ierr);
98fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNEnd",          DM_CLASSID,&DMPLEX_GlobalToNaturalEnd);CHKERRQ(ierr);
99fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGBegin",        DM_CLASSID,&DMPLEX_NaturalToGlobalBegin);CHKERRQ(ierr);
100fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGEnd",          DM_CLASSID,&DMPLEX_NaturalToGlobalEnd);CHKERRQ(ierr);
101e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexStratify",         DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr);
10230b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexSymmetrize",       DM_CLASSID,&DMPLEX_Symmetrize);CHKERRQ(ierr);
10375a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexPrealloc",         DM_CLASSID,&DMPLEX_Preallocate);CHKERRQ(ierr);
10475a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexResidualFE",       DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr);
10575a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexJacobianFE",       DM_CLASSID,&DMPLEX_JacobianFEM);CHKERRQ(ierr);
10675a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpFE",         DM_CLASSID,&DMPLEX_InterpolatorFEM);CHKERRQ(ierr);
10775a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInjectorFE",       DM_CLASSID,&DMPLEX_InjectorFEM);CHKERRQ(ierr);
108c1f031eeSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexIntegralFEM",      DM_CLASSID,&DMPLEX_IntegralFEM);CHKERRQ(ierr);
1093b3bc66dSMichael Lange   ierr = PetscLogEventRegister("DMPlexCreateGmsh",       DM_CLASSID,&DMPLEX_CreateGmsh);CHKERRQ(ierr);
11030b0ce1bSStefano Zampini   ierr = PetscLogEventRegister("DMPlexRebalance",        DM_CLASSID,&DMPLEX_RebalanceSharedPoints);CHKERRQ(ierr);
111ed923d71SDave May 
112ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmMigrate",         DM_CLASSID,&DMSWARM_Migrate);CHKERRQ(ierr);
113ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDETSetup",        DM_CLASSID,&DMSWARM_DataExchangerTopologySetup);CHKERRQ(ierr);
114ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDExBegin",        DM_CLASSID,&DMSWARM_DataExchangerBegin);CHKERRQ(ierr);
115ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDExEnd",          DM_CLASSID,&DMSWARM_DataExchangerEnd);CHKERRQ(ierr);
116ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDESendCnt",       DM_CLASSID,&DMSWARM_DataExchangerSendCount);CHKERRQ(ierr);
117ed923d71SDave May   ierr = PetscLogEventRegister("DMSwarmDEPack",          DM_CLASSID,&DMSWARM_DataExchangerPack);CHKERRQ(ierr);
118f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmAddPnts",         DM_CLASSID,&DMSWARM_AddPoints);CHKERRQ(ierr);
119f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmRmvPnts",         DM_CLASSID,&DMSWARM_RemovePoints);CHKERRQ(ierr);
120f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmSort",            DM_CLASSID,&DMSWARM_Sort);CHKERRQ(ierr);
121f2b2bee7SDave May   ierr = PetscLogEventRegister("DMSwarmSetSizes",        DM_CLASSID,&DMSWARM_SetSizes);CHKERRQ(ierr);
122ed923d71SDave May 
123e8597998SBarry Smith   /* Process info exclusions */
1248e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
125e8597998SBarry Smith   if (opt) {
1268e81d068SLisandro Dalcin     ierr = PetscStrInList("dm",logList,',',&pkg);CHKERRQ(ierr);
1278e81d068SLisandro Dalcin     if (pkg) {ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr);}
128e8597998SBarry Smith   }
1298e81d068SLisandro Dalcin 
130e8597998SBarry Smith   /* Process summary exclusions */
1318e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
132e8597998SBarry Smith   if (opt) {
1338e81d068SLisandro Dalcin     ierr = PetscStrInList("dm",logList,',',&pkg);CHKERRQ(ierr);
134fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(DM_CLASSID);CHKERRQ(ierr);}
135e8597998SBarry Smith   }
1368e81d068SLisandro Dalcin 
1373a074057SBarry Smith   ierr = DMPlexGenerateRegisterAll();CHKERRQ(ierr);
1383a074057SBarry Smith   ierr = PetscRegisterFinalize(DMPlexGenerateRegisterDestroy);CHKERRQ(ierr);
139e8597998SBarry Smith   ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr);
140e8597998SBarry Smith   PetscFunctionReturn(0);
141e8597998SBarry Smith }
14206759e06SMatthew G. Knepley #include <petscfe.h>
143e8597998SBarry Smith 
14406759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE;
14506759e06SMatthew G. Knepley /*@C
14606759e06SMatthew G. Knepley   PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called
14706759e06SMatthew G. Knepley   from PetscFinalize().
148e8597998SBarry Smith 
14906759e06SMatthew G. Knepley   Level: developer
15006759e06SMatthew G. Knepley 
15106759e06SMatthew G. Knepley .seealso: PetscInitialize()
15206759e06SMatthew G. Knepley @*/
15306759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void)
15406759e06SMatthew G. Knepley {
15506759e06SMatthew G. Knepley   PetscErrorCode ierr;
15606759e06SMatthew G. Knepley 
15706759e06SMatthew G. Knepley   PetscFunctionBegin;
15806759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr);
15906759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr);
1600483ade4SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFEList);CHKERRQ(ierr);
16106759e06SMatthew G. Knepley   PetscFEPackageInitialized       = PETSC_FALSE;
16206759e06SMatthew G. Knepley   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
16306759e06SMatthew G. Knepley   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
1640483ade4SMatthew G. Knepley   PetscFERegisterAllCalled        = PETSC_FALSE;
16506759e06SMatthew G. Knepley   PetscFunctionReturn(0);
16606759e06SMatthew G. Knepley }
16706759e06SMatthew G. Knepley 
16806759e06SMatthew G. Knepley /*@C
16906759e06SMatthew G. Knepley   PetscFEInitializePackage - This function initializes everything in the FE package. It is called
17006759e06SMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate()
17106759e06SMatthew G. Knepley   when using static libraries.
17206759e06SMatthew G. Knepley 
17306759e06SMatthew G. Knepley   Level: developer
17406759e06SMatthew G. Knepley 
17506759e06SMatthew G. Knepley .seealso: PetscInitialize()
17606759e06SMatthew G. Knepley @*/
17706759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void)
17806759e06SMatthew G. Knepley {
17906759e06SMatthew G. Knepley   char           logList[256];
1808e81d068SLisandro Dalcin   PetscBool      opt,pkg;
18106759e06SMatthew G. Knepley   PetscErrorCode ierr;
18206759e06SMatthew G. Knepley 
18306759e06SMatthew G. Knepley   PetscFunctionBegin;
18406759e06SMatthew G. Knepley   if (PetscFEPackageInitialized) PetscFunctionReturn(0);
18506759e06SMatthew G. Knepley   PetscFEPackageInitialized = PETSC_TRUE;
18606759e06SMatthew G. Knepley 
18706759e06SMatthew G. Knepley   /* Register Classes */
18806759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr);
18906759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Dual Space",   &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr);
19006759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("FE Space",     &PETSCFE_CLASSID);CHKERRQ(ierr);
19106759e06SMatthew G. Knepley   /* Register Constructors */
19206759e06SMatthew G. Knepley   ierr = PetscSpaceRegisterAll();CHKERRQ(ierr);
1930483ade4SMatthew G. Knepley   ierr = PetscDualSpaceRegisterAll();CHKERRQ(ierr);
1940483ade4SMatthew G. Knepley   ierr = PetscFERegisterAll();CHKERRQ(ierr);
19506759e06SMatthew G. Knepley   /* Register Events */
19606759e06SMatthew G. Knepley   /* Process info exclusions */
1978e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
19806759e06SMatthew G. Knepley   if (opt) {
1998e81d068SLisandro Dalcin     ierr = PetscStrInList("fe",logList,',',&pkg);CHKERRQ(ierr);
2008e81d068SLisandro Dalcin     if (pkg) {ierr = PetscInfoDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
20106759e06SMatthew G. Knepley   }
20206759e06SMatthew G. Knepley   /* Process summary exclusions */
2038e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
20406759e06SMatthew G. Knepley   if (opt) {
2058e81d068SLisandro Dalcin     ierr = PetscStrInList("fe",logList,',',&pkg);CHKERRQ(ierr);
206fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
20706759e06SMatthew G. Knepley   }
2088e81d068SLisandro Dalcin   /* Register package finalizer */
20906759e06SMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr);
21006759e06SMatthew G. Knepley   PetscFunctionReturn(0);
21106759e06SMatthew G. Knepley }
212f62f30faSMatthew G. Knepley #include <petscfv.h>
213f62f30faSMatthew G. Knepley 
214f62f30faSMatthew G. Knepley static PetscBool PetscFVPackageInitialized = PETSC_FALSE;
215f62f30faSMatthew G. Knepley /*@C
216f62f30faSMatthew G. Knepley   PetscFVFinalizePackage - This function finalizes everything in the PetscFV package. It is called
217f62f30faSMatthew G. Knepley   from PetscFinalize().
218f62f30faSMatthew G. Knepley 
219f62f30faSMatthew G. Knepley   Level: developer
220f62f30faSMatthew G. Knepley 
221f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
222f62f30faSMatthew G. Knepley @*/
223f62f30faSMatthew G. Knepley PetscErrorCode PetscFVFinalizePackage(void)
224f62f30faSMatthew G. Knepley {
225f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
226f62f30faSMatthew G. Knepley 
227f62f30faSMatthew G. Knepley   PetscFunctionBegin;
228ab2453f0SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscLimiterList);CHKERRQ(ierr);
229f62f30faSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFVList);CHKERRQ(ierr);
230f62f30faSMatthew G. Knepley   PetscFVPackageInitialized     = PETSC_FALSE;
231f62f30faSMatthew G. Knepley   PetscFVRegisterAllCalled      = PETSC_FALSE;
232ab2453f0SMatthew G. Knepley   PetscLimiterRegisterAllCalled = PETSC_FALSE;
233f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
234f62f30faSMatthew G. Knepley }
235f62f30faSMatthew G. Knepley 
236f62f30faSMatthew G. Knepley /*@C
237f62f30faSMatthew G. Knepley   PetscFVInitializePackage - This function initializes everything in the FV package. It is called
238f62f30faSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscFVCreate()
239f62f30faSMatthew G. Knepley   when using static libraries.
240f62f30faSMatthew G. Knepley 
241f62f30faSMatthew G. Knepley   Level: developer
242f62f30faSMatthew G. Knepley 
243f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
244f62f30faSMatthew G. Knepley @*/
245f62f30faSMatthew G. Knepley PetscErrorCode PetscFVInitializePackage(void)
246f62f30faSMatthew G. Knepley {
247f62f30faSMatthew G. Knepley   char           logList[256];
2488e81d068SLisandro Dalcin   PetscBool      opt,pkg;
249f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
250f62f30faSMatthew G. Knepley 
251f62f30faSMatthew G. Knepley   PetscFunctionBegin;
252f62f30faSMatthew G. Knepley   if (PetscFVPackageInitialized) PetscFunctionReturn(0);
253f62f30faSMatthew G. Knepley   PetscFVPackageInitialized = PETSC_TRUE;
254f62f30faSMatthew G. Knepley 
255f62f30faSMatthew G. Knepley   /* Register Classes */
256f62f30faSMatthew G. Knepley   ierr = PetscClassIdRegister("FV Space", &PETSCFV_CLASSID);CHKERRQ(ierr);
257ab2453f0SMatthew G. Knepley   ierr = PetscClassIdRegister("Limiter",  &PETSCLIMITER_CLASSID);CHKERRQ(ierr);
258f62f30faSMatthew G. Knepley   /* Register Constructors */
259f62f30faSMatthew G. Knepley   ierr = PetscFVRegisterAll();CHKERRQ(ierr);
260f62f30faSMatthew G. Knepley   /* Register Events */
261f62f30faSMatthew G. Knepley   /* Process info exclusions */
2628e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
263f62f30faSMatthew G. Knepley   if (opt) {
2648e81d068SLisandro Dalcin     ierr = PetscStrInList("fv",logList,',',&pkg);CHKERRQ(ierr);
2658e81d068SLisandro Dalcin     if (pkg) {ierr = PetscInfoDeactivateClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
2668e81d068SLisandro Dalcin     ierr = PetscStrInList("limiter",logList,',',&pkg);CHKERRQ(ierr);
2678e81d068SLisandro Dalcin     if (pkg) {ierr = PetscInfoDeactivateClass(PETSCLIMITER_CLASSID);CHKERRQ(ierr);}
268f62f30faSMatthew G. Knepley   }
269f62f30faSMatthew G. Knepley   /* Process summary exclusions */
2708e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
271f62f30faSMatthew G. Knepley   if (opt) {
2728e81d068SLisandro Dalcin     ierr = PetscStrInList("fv",logList,',',&pkg);CHKERRQ(ierr);
273fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
2748e81d068SLisandro Dalcin     ierr = PetscStrInList("limiter",logList,',',&pkg);CHKERRQ(ierr);
275fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCLIMITER_CLASSID);CHKERRQ(ierr);}
276f62f30faSMatthew G. Knepley   }
2778e81d068SLisandro Dalcin   /* Register package finalizer */
278f62f30faSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFVFinalizePackage);CHKERRQ(ierr);
279f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
280f62f30faSMatthew G. Knepley }
2812764a2aaSMatthew G. Knepley #include <petscds.h>
282022a7a5cSMatthew G. Knepley 
2832764a2aaSMatthew G. Knepley static PetscBool PetscDSPackageInitialized = PETSC_FALSE;
284022a7a5cSMatthew G. Knepley /*@C
2852764a2aaSMatthew G. Knepley   PetscDSFinalizePackage - This function finalizes everything in the PetscDS package. It is called
286022a7a5cSMatthew G. Knepley   from PetscFinalize().
287022a7a5cSMatthew G. Knepley 
288022a7a5cSMatthew G. Knepley   Level: developer
289022a7a5cSMatthew G. Knepley 
290022a7a5cSMatthew G. Knepley .seealso: PetscInitialize()
291022a7a5cSMatthew G. Knepley @*/
2922764a2aaSMatthew G. Knepley PetscErrorCode PetscDSFinalizePackage(void)
293022a7a5cSMatthew G. Knepley {
294022a7a5cSMatthew G. Knepley   PetscErrorCode ierr;
295022a7a5cSMatthew G. Knepley 
296022a7a5cSMatthew G. Knepley   PetscFunctionBegin;
2972764a2aaSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDSList);CHKERRQ(ierr);
2982764a2aaSMatthew G. Knepley   PetscDSPackageInitialized = PETSC_FALSE;
2992764a2aaSMatthew G. Knepley   PetscDSRegisterAllCalled  = PETSC_FALSE;
300022a7a5cSMatthew G. Knepley   PetscFunctionReturn(0);
301022a7a5cSMatthew G. Knepley }
302022a7a5cSMatthew G. Knepley 
303022a7a5cSMatthew G. Knepley /*@C
3042764a2aaSMatthew G. Knepley   PetscDSInitializePackage - This function initializes everything in the DS package. It is called
3052764a2aaSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscDSCreate()
306022a7a5cSMatthew G. Knepley   when using static libraries.
307022a7a5cSMatthew G. Knepley 
308022a7a5cSMatthew G. Knepley   Level: developer
309022a7a5cSMatthew G. Knepley 
310022a7a5cSMatthew G. Knepley .seealso: PetscInitialize()
311022a7a5cSMatthew G. Knepley @*/
3122764a2aaSMatthew G. Knepley PetscErrorCode PetscDSInitializePackage(void)
313022a7a5cSMatthew G. Knepley {
314022a7a5cSMatthew G. Knepley   char           logList[256];
3158e81d068SLisandro Dalcin   PetscBool      opt,pkg;
316022a7a5cSMatthew G. Knepley   PetscErrorCode ierr;
317022a7a5cSMatthew G. Knepley 
318022a7a5cSMatthew G. Knepley   PetscFunctionBegin;
3192764a2aaSMatthew G. Knepley   if (PetscDSPackageInitialized) PetscFunctionReturn(0);
3202764a2aaSMatthew G. Knepley   PetscDSPackageInitialized = PETSC_TRUE;
321022a7a5cSMatthew G. Knepley 
322022a7a5cSMatthew G. Knepley   /* Register Classes */
3232764a2aaSMatthew G. Knepley   ierr = PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID);CHKERRQ(ierr);
324022a7a5cSMatthew G. Knepley   /* Register Constructors */
3252764a2aaSMatthew G. Knepley   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
326022a7a5cSMatthew G. Knepley   /* Register Events */
327022a7a5cSMatthew G. Knepley   /* Process info exclusions */
3288e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-info_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
329022a7a5cSMatthew G. Knepley   if (opt) {
3308e81d068SLisandro Dalcin     ierr = PetscStrInList("ds",logList,',',&pkg);CHKERRQ(ierr);
3318e81d068SLisandro Dalcin     if (pkg) {ierr = PetscInfoDeactivateClass(PETSCDS_CLASSID);CHKERRQ(ierr);}
332022a7a5cSMatthew G. Knepley   }
333022a7a5cSMatthew G. Knepley   /* Process summary exclusions */
3348e81d068SLisandro Dalcin   ierr = PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);CHKERRQ(ierr);
335022a7a5cSMatthew G. Knepley   if (opt) {
3368e81d068SLisandro Dalcin     ierr = PetscStrInList("ds",logList,',',&pkg);CHKERRQ(ierr);
337fa2bb9feSLisandro Dalcin     if (pkg) {ierr = PetscLogEventExcludeClass(PETSCDS_CLASSID);CHKERRQ(ierr);}
338022a7a5cSMatthew G. Knepley   }
3398e81d068SLisandro Dalcin   /* Register package finalizer */
3402764a2aaSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscDSFinalizePackage);CHKERRQ(ierr);
341022a7a5cSMatthew G. Knepley   PetscFunctionReturn(0);
342022a7a5cSMatthew G. Knepley }
343e8597998SBarry Smith 
344aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
345e8597998SBarry Smith /*
346e8597998SBarry Smith   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
347e8597998SBarry Smith 
348e8597998SBarry Smith   This one registers all the mesh generators and partitioners that are in
349e8597998SBarry Smith   the basic DM library.
350e8597998SBarry Smith 
351e8597998SBarry Smith */
352607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
353e8597998SBarry Smith {
354e8597998SBarry Smith   PetscErrorCode ierr;
355e8597998SBarry Smith 
356e8597998SBarry Smith   PetscFunctionBegin;
357607a6623SBarry Smith   ierr = AOInitializePackage();CHKERRQ(ierr);
358607a6623SBarry Smith   ierr = DMInitializePackage();CHKERRQ(ierr);
35906759e06SMatthew G. Knepley   ierr = PetscFEInitializePackage();CHKERRQ(ierr);
360ab2453f0SMatthew G. Knepley   ierr = PetscFVInitializePackage();CHKERRQ(ierr);
3613da551e6SToby Isaac   ierr = DMFieldInitializePackage();CHKERRQ(ierr);
362e8597998SBarry Smith   PetscFunctionReturn(0);
363e8597998SBarry Smith }
364e8597998SBarry Smith 
365aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */
366