xref: /petsc/src/dm/interface/dlregisdmdm.c (revision 25afeb17e9e865b57b5c42d8077468a4a09365f2)
1e8597998SBarry Smith 
25fdea053SToby Isaac #include <petsc/private/dmlabelimpl.h>
3af0996ceSBarry Smith #include <petsc/private/dmdaimpl.h>
4af0996ceSBarry Smith #include <petsc/private/dmpleximpl.h>
5af0996ceSBarry Smith #include <petsc/private/petscdsimpl.h>
6af0996ceSBarry Smith #include <petsc/private/petscfeimpl.h>
7af0996ceSBarry Smith #include <petsc/private/petscfvimpl.h>
8e8597998SBarry Smith 
9e8597998SBarry Smith static PetscBool DMPackageInitialized = PETSC_FALSE;
10e8597998SBarry Smith #undef __FUNCT__
11e8597998SBarry Smith #define __FUNCT__ "DMFinalizePackage"
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 .keywords: AO, initialize, package
19e8597998SBarry Smith .seealso: PetscInitialize()
20e8597998SBarry Smith @*/
21e8597998SBarry Smith PetscErrorCode  DMFinalizePackage(void)
22e8597998SBarry Smith {
23e8597998SBarry Smith   PetscErrorCode ierr;
24e8597998SBarry Smith 
25e8597998SBarry Smith   PetscFunctionBegin;
2677623264SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscPartitionerList);CHKERRQ(ierr);
2737e93019SBarry Smith   ierr = PetscFunctionListDestroy(&DMList);CHKERRQ(ierr);
28e8597998SBarry Smith   DMPackageInitialized = PETSC_FALSE;
29e8597998SBarry Smith   DMRegisterAllCalled  = PETSC_FALSE;
3077623264SMatthew G. Knepley   PetscPartitionerRegisterAllCalled = PETSC_FALSE;
31e8597998SBarry Smith   PetscFunctionReturn(0);
32e8597998SBarry Smith }
33e8597998SBarry Smith 
34e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
358cc058d9SJed Brown PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat);
36e8597998SBarry Smith #endif
37e8597998SBarry Smith 
38e8597998SBarry Smith #undef __FUNCT__
39e8597998SBarry Smith #define __FUNCT__ "DMInitializePackage"
40e8597998SBarry Smith /*@C
41e8597998SBarry Smith   DMInitializePackage - This function initializes everything in the DM package. It is called
42e8597998SBarry Smith   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate()
43e8597998SBarry Smith   or DMDACreate() when using static libraries.
44e8597998SBarry Smith 
45e8597998SBarry Smith   Level: developer
46e8597998SBarry Smith 
47e8597998SBarry Smith .keywords: AO, initialize, package
48e8597998SBarry Smith .seealso: PetscInitialize()
49e8597998SBarry Smith @*/
50607a6623SBarry Smith PetscErrorCode  DMInitializePackage(void)
51e8597998SBarry Smith {
52e8597998SBarry Smith   char           logList[256];
53e8597998SBarry Smith   char           *className;
54e8597998SBarry Smith   PetscBool      opt;
55e8597998SBarry Smith   PetscErrorCode ierr;
56e8597998SBarry Smith 
57e8597998SBarry Smith   PetscFunctionBegin;
58e8597998SBarry Smith   if (DMPackageInitialized) PetscFunctionReturn(0);
59e8597998SBarry Smith   DMPackageInitialized = PETSC_TRUE;
60e8597998SBarry Smith 
61e8597998SBarry Smith   /* Register Classes */
62e8597998SBarry Smith   ierr = PetscClassIdRegister("Distributed Mesh",&DM_CLASSID);CHKERRQ(ierr);
6377623264SMatthew G. Knepley   ierr = PetscClassIdRegister("GraphPartitioner",&PETSCPARTITIONER_CLASSID);CHKERRQ(ierr);
64e8597998SBarry Smith 
65e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
66bdf89e91SBarry Smith   ierr = MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);CHKERRQ(ierr);
67e8597998SBarry Smith #endif
685fdea053SToby Isaac   ierr = PetscSectionSymRegister(PETSCSECTIONSYMLABEL,PetscSectionSymCreate_Label);CHKERRQ(ierr);
69e8597998SBarry Smith 
70e8597998SBarry Smith   /* Register Constructors */
71607a6623SBarry Smith   ierr = DMRegisterAll();CHKERRQ(ierr);
72e8597998SBarry Smith   /* Register Events */
73e8597998SBarry Smith   ierr = PetscLogEventRegister("DMConvert",              DM_CLASSID,&DM_Convert);CHKERRQ(ierr);
74e8597998SBarry Smith   ierr = PetscLogEventRegister("DMGlobalToLocal",        DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr);
75e8597998SBarry Smith   ierr = PetscLogEventRegister("DMLocalToGlobal",        DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr);
7647a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMLocatePoints",         DM_CLASSID,&DM_LocatePoints);CHKERRQ(ierr);
7747a35634SPatrick Farrell   ierr = PetscLogEventRegister("DMCoarsen",              DM_CLASSID,&DM_Coarsen);CHKERRQ(ierr);
7842ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateInterp",         DM_CLASSID,&DM_CreateInterpolation);CHKERRQ(ierr);
7942ac0407SBarry Smith   ierr = PetscLogEventRegister("DMCreateRestrict",       DM_CLASSID,&DM_CreateRestriction);CHKERRQ(ierr);
80e8597998SBarry Smith 
81e8597998SBarry Smith   ierr = PetscLogEventRegister("DMDALocalADFunc",        DM_CLASSID,&DMDA_LocalADFunction);CHKERRQ(ierr);
82e8597998SBarry Smith 
8377623264SMatthew G. Knepley   ierr = PetscLogEventRegister("Mesh Partition",         PETSCPARTITIONER_CLASSID,&PETSCPARTITIONER_Partition);CHKERRQ(ierr);
841b858b30SMichael Lange   ierr = PetscLogEventRegister("Mesh Migration",         DM_CLASSID,&DMPLEX_Migrate);CHKERRQ(ierr);
8575a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterp",           DM_CLASSID,&DMPLEX_Interpolate);CHKERRQ(ierr);
86e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexDistribute",       DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr);
8775a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistCones",        DM_CLASSID,&DMPLEX_DistributeCones);CHKERRQ(ierr);
8875a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistLabels",       DM_CLASSID,&DMPLEX_DistributeLabels);CHKERRQ(ierr);
891337e6e5SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribSF",        DM_CLASSID,&DMPLEX_DistributeSF);CHKERRQ(ierr);
903d822a50SMichael Lange   ierr = PetscLogEventRegister("DMPlexDistribOL",        DM_CLASSID,&DMPLEX_DistributeOverlap);CHKERRQ(ierr);
9175a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistField",        DM_CLASSID,&DMPLEX_DistributeField);CHKERRQ(ierr);
9275a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistData",         DM_CLASSID,&DMPLEX_DistributeData);CHKERRQ(ierr);
93*25afeb17SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpSF",         DM_CLASSID,&DMPLEX_InterpolateSF);CHKERRQ(ierr);
94fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNBegin",        DM_CLASSID,&DMPLEX_GlobalToNaturalBegin);CHKERRQ(ierr);
95fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexGToNEnd",          DM_CLASSID,&DMPLEX_GlobalToNaturalEnd);CHKERRQ(ierr);
96fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGBegin",        DM_CLASSID,&DMPLEX_NaturalToGlobalBegin);CHKERRQ(ierr);
97fa534816SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexNToGEnd",          DM_CLASSID,&DMPLEX_NaturalToGlobalEnd);CHKERRQ(ierr);
98e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexStratify",         DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr);
9975a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexPrealloc",         DM_CLASSID,&DMPLEX_Preallocate);CHKERRQ(ierr);
10075a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexResidualFE",       DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr);
10175a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexJacobianFE",       DM_CLASSID,&DMPLEX_JacobianFEM);CHKERRQ(ierr);
10275a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpFE",         DM_CLASSID,&DMPLEX_InterpolatorFEM);CHKERRQ(ierr);
10375a69067SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInjectorFE",       DM_CLASSID,&DMPLEX_InjectorFEM);CHKERRQ(ierr);
104c1f031eeSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexIntegralFEM",      DM_CLASSID,&DMPLEX_IntegralFEM);CHKERRQ(ierr);
1053b3bc66dSMichael Lange   ierr = PetscLogEventRegister("DMPlexCreateGmsh",       DM_CLASSID,&DMPLEX_CreateGmsh);CHKERRQ(ierr);
106e8597998SBarry Smith   /* Process info exclusions */
107c5929fdfSBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
108e8597998SBarry Smith   if (opt) {
109e8597998SBarry Smith     ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr);
110e8597998SBarry Smith     if (className) {
111e8597998SBarry Smith       ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr);
112e8597998SBarry Smith     }
113e8597998SBarry Smith   }
114e8597998SBarry Smith   /* Process summary exclusions */
1157bf5a629SBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
116e8597998SBarry Smith   if (opt) {
117e8597998SBarry Smith     ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr);
118e8597998SBarry Smith     if (className) {
119e8597998SBarry Smith       ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr);
120e8597998SBarry Smith     }
121e8597998SBarry Smith   }
122e8597998SBarry Smith   ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr);
123e8597998SBarry Smith   PetscFunctionReturn(0);
124e8597998SBarry Smith }
12506759e06SMatthew G. Knepley #include <petscfe.h>
126e8597998SBarry Smith 
12706759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE;
12806759e06SMatthew G. Knepley #undef __FUNCT__
12906759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEFinalizePackage"
13006759e06SMatthew G. Knepley /*@C
13106759e06SMatthew G. Knepley   PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called
13206759e06SMatthew G. Knepley   from PetscFinalize().
133e8597998SBarry Smith 
13406759e06SMatthew G. Knepley   Level: developer
13506759e06SMatthew G. Knepley 
13606759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package
13706759e06SMatthew G. Knepley .seealso: PetscInitialize()
13806759e06SMatthew G. Knepley @*/
13906759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void)
14006759e06SMatthew G. Knepley {
14106759e06SMatthew G. Knepley   PetscErrorCode ierr;
14206759e06SMatthew G. Knepley 
14306759e06SMatthew G. Knepley   PetscFunctionBegin;
14406759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr);
14506759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr);
1460483ade4SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFEList);CHKERRQ(ierr);
14706759e06SMatthew G. Knepley   PetscFEPackageInitialized       = PETSC_FALSE;
14806759e06SMatthew G. Knepley   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
14906759e06SMatthew G. Knepley   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
1500483ade4SMatthew G. Knepley   PetscFERegisterAllCalled        = PETSC_FALSE;
15106759e06SMatthew G. Knepley   PetscFunctionReturn(0);
15206759e06SMatthew G. Knepley }
15306759e06SMatthew G. Knepley 
15406759e06SMatthew G. Knepley #undef __FUNCT__
15506759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEInitializePackage"
15606759e06SMatthew G. Knepley /*@C
15706759e06SMatthew G. Knepley   PetscFEInitializePackage - This function initializes everything in the FE package. It is called
15806759e06SMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate()
15906759e06SMatthew G. Knepley   when using static libraries.
16006759e06SMatthew G. Knepley 
16106759e06SMatthew G. Knepley   Level: developer
16206759e06SMatthew G. Knepley 
16306759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package
16406759e06SMatthew G. Knepley .seealso: PetscInitialize()
16506759e06SMatthew G. Knepley @*/
16606759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void)
16706759e06SMatthew G. Knepley {
16806759e06SMatthew G. Knepley   char           logList[256];
16906759e06SMatthew G. Knepley   char          *className;
17006759e06SMatthew G. Knepley   PetscBool      opt;
17106759e06SMatthew G. Knepley   PetscErrorCode ierr;
17206759e06SMatthew G. Knepley 
17306759e06SMatthew G. Knepley   PetscFunctionBegin;
17406759e06SMatthew G. Knepley   if (PetscFEPackageInitialized) PetscFunctionReturn(0);
17506759e06SMatthew G. Knepley   PetscFEPackageInitialized = PETSC_TRUE;
17606759e06SMatthew G. Knepley 
17706759e06SMatthew G. Knepley   /* Register Classes */
17806759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr);
17906759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Dual Space",   &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr);
18006759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("FE Space",     &PETSCFE_CLASSID);CHKERRQ(ierr);
18106759e06SMatthew G. Knepley 
18206759e06SMatthew G. Knepley   /* Register Constructors */
18306759e06SMatthew G. Knepley   ierr = PetscSpaceRegisterAll();CHKERRQ(ierr);
1840483ade4SMatthew G. Knepley   ierr = PetscDualSpaceRegisterAll();CHKERRQ(ierr);
1850483ade4SMatthew G. Knepley   ierr = PetscFERegisterAll();CHKERRQ(ierr);
18606759e06SMatthew G. Knepley   /* Register Events */
18706759e06SMatthew G. Knepley   /* Process info exclusions */
188c5929fdfSBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
18906759e06SMatthew G. Knepley   if (opt) {
19006759e06SMatthew G. Knepley     ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr);
191f62f30faSMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
19206759e06SMatthew G. Knepley   }
19306759e06SMatthew G. Knepley   /* Process summary exclusions */
1947bf5a629SBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
19506759e06SMatthew G. Knepley   if (opt) {
196f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr);
197f62f30faSMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
19806759e06SMatthew G. Knepley   }
19906759e06SMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr);
20006759e06SMatthew G. Knepley   PetscFunctionReturn(0);
20106759e06SMatthew G. Knepley }
202f62f30faSMatthew G. Knepley #include <petscfv.h>
203f62f30faSMatthew G. Knepley 
204f62f30faSMatthew G. Knepley static PetscBool PetscFVPackageInitialized = PETSC_FALSE;
205f62f30faSMatthew G. Knepley #undef __FUNCT__
206f62f30faSMatthew G. Knepley #define __FUNCT__ "PetscFVFinalizePackage"
207f62f30faSMatthew G. Knepley /*@C
208f62f30faSMatthew G. Knepley   PetscFVFinalizePackage - This function finalizes everything in the PetscFV package. It is called
209f62f30faSMatthew G. Knepley   from PetscFinalize().
210f62f30faSMatthew G. Knepley 
211f62f30faSMatthew G. Knepley   Level: developer
212f62f30faSMatthew G. Knepley 
213f62f30faSMatthew G. Knepley .keywords: PetscFV, initialize, package
214f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
215f62f30faSMatthew G. Knepley @*/
216f62f30faSMatthew G. Knepley PetscErrorCode PetscFVFinalizePackage(void)
217f62f30faSMatthew G. Knepley {
218f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
219f62f30faSMatthew G. Knepley 
220f62f30faSMatthew G. Knepley   PetscFunctionBegin;
221ab2453f0SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscLimiterList);CHKERRQ(ierr);
222f62f30faSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFVList);CHKERRQ(ierr);
223f62f30faSMatthew G. Knepley   PetscFVPackageInitialized     = PETSC_FALSE;
224f62f30faSMatthew G. Knepley   PetscFVRegisterAllCalled      = PETSC_FALSE;
225ab2453f0SMatthew G. Knepley   PetscLimiterRegisterAllCalled = PETSC_FALSE;
226f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
227f62f30faSMatthew G. Knepley }
228f62f30faSMatthew G. Knepley 
229f62f30faSMatthew G. Knepley #undef __FUNCT__
230f62f30faSMatthew G. Knepley #define __FUNCT__ "PetscFVInitializePackage"
231f62f30faSMatthew G. Knepley /*@C
232f62f30faSMatthew G. Knepley   PetscFVInitializePackage - This function initializes everything in the FV package. It is called
233f62f30faSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscFVCreate()
234f62f30faSMatthew G. Knepley   when using static libraries.
235f62f30faSMatthew G. Knepley 
236f62f30faSMatthew G. Knepley   Level: developer
237f62f30faSMatthew G. Knepley 
238f62f30faSMatthew G. Knepley .keywords: PetscFV, initialize, package
239f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
240f62f30faSMatthew G. Knepley @*/
241f62f30faSMatthew G. Knepley PetscErrorCode PetscFVInitializePackage(void)
242f62f30faSMatthew G. Knepley {
243f62f30faSMatthew G. Knepley   char           logList[256];
244f62f30faSMatthew G. Knepley   char          *className;
245f62f30faSMatthew G. Knepley   PetscBool      opt;
246f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
247f62f30faSMatthew G. Knepley 
248f62f30faSMatthew G. Knepley   PetscFunctionBegin;
249f62f30faSMatthew G. Knepley   if (PetscFVPackageInitialized) PetscFunctionReturn(0);
250f62f30faSMatthew G. Knepley   PetscFVPackageInitialized = PETSC_TRUE;
251f62f30faSMatthew G. Knepley 
252f62f30faSMatthew G. Knepley   /* Register Classes */
253f62f30faSMatthew G. Knepley   ierr = PetscClassIdRegister("FV Space", &PETSCFV_CLASSID);CHKERRQ(ierr);
254ab2453f0SMatthew G. Knepley   ierr = PetscClassIdRegister("Limiter",  &PETSCLIMITER_CLASSID);CHKERRQ(ierr);
255f62f30faSMatthew G. Knepley 
256f62f30faSMatthew G. Knepley   /* Register Constructors */
257f62f30faSMatthew G. Knepley   ierr = PetscFVRegisterAll();CHKERRQ(ierr);
258f62f30faSMatthew G. Knepley   /* Register Events */
259f62f30faSMatthew G. Knepley   /* Process info exclusions */
260c5929fdfSBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
261f62f30faSMatthew G. Knepley   if (opt) {
262f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fv", &className);CHKERRQ(ierr);
263f62f30faSMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
264ab2453f0SMatthew G. Knepley     ierr = PetscStrstr(logList, "limiter", &className);CHKERRQ(ierr);
265ab2453f0SMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCLIMITER_CLASSID);CHKERRQ(ierr);}
266f62f30faSMatthew G. Knepley   }
267f62f30faSMatthew G. Knepley   /* Process summary exclusions */
2687bf5a629SBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
269f62f30faSMatthew G. Knepley   if (opt) {
270f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fv", &className);CHKERRQ(ierr);
271f62f30faSMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
272ab2453f0SMatthew G. Knepley     ierr = PetscStrstr(logList, "limiter", &className);CHKERRQ(ierr);
273ab2453f0SMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCLIMITER_CLASSID);CHKERRQ(ierr);}
274f62f30faSMatthew G. Knepley   }
275f62f30faSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFVFinalizePackage);CHKERRQ(ierr);
276f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
277f62f30faSMatthew G. Knepley }
2782764a2aaSMatthew G. Knepley #include <petscds.h>
279022a7a5cSMatthew G. Knepley 
2802764a2aaSMatthew G. Knepley static PetscBool PetscDSPackageInitialized = PETSC_FALSE;
281022a7a5cSMatthew G. Knepley #undef __FUNCT__
2822764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSFinalizePackage"
283022a7a5cSMatthew G. Knepley /*@C
2842764a2aaSMatthew G. Knepley   PetscDSFinalizePackage - This function finalizes everything in the PetscDS package. It is called
285022a7a5cSMatthew G. Knepley   from PetscFinalize().
286022a7a5cSMatthew G. Knepley 
287022a7a5cSMatthew G. Knepley   Level: developer
288022a7a5cSMatthew G. Knepley 
2892764a2aaSMatthew G. Knepley .keywords: PetscDS, initialize, package
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 #undef __FUNCT__
3042764a2aaSMatthew G. Knepley #define __FUNCT__ "PetscDSInitializePackage"
305022a7a5cSMatthew G. Knepley /*@C
3062764a2aaSMatthew G. Knepley   PetscDSInitializePackage - This function initializes everything in the DS package. It is called
3072764a2aaSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscDSCreate()
308022a7a5cSMatthew G. Knepley   when using static libraries.
309022a7a5cSMatthew G. Knepley 
310022a7a5cSMatthew G. Knepley   Level: developer
311022a7a5cSMatthew G. Knepley 
3122764a2aaSMatthew G. Knepley .keywords: PetscDS, initialize, package
313022a7a5cSMatthew G. Knepley .seealso: PetscInitialize()
314022a7a5cSMatthew G. Knepley @*/
3152764a2aaSMatthew G. Knepley PetscErrorCode PetscDSInitializePackage(void)
316022a7a5cSMatthew G. Knepley {
317022a7a5cSMatthew G. Knepley   char           logList[256];
318022a7a5cSMatthew G. Knepley   char          *className;
319022a7a5cSMatthew G. Knepley   PetscBool      opt;
320022a7a5cSMatthew G. Knepley   PetscErrorCode ierr;
321022a7a5cSMatthew G. Knepley 
322022a7a5cSMatthew G. Knepley   PetscFunctionBegin;
3232764a2aaSMatthew G. Knepley   if (PetscDSPackageInitialized) PetscFunctionReturn(0);
3242764a2aaSMatthew G. Knepley   PetscDSPackageInitialized = PETSC_TRUE;
325022a7a5cSMatthew G. Knepley 
326022a7a5cSMatthew G. Knepley   /* Register Classes */
3272764a2aaSMatthew G. Knepley   ierr = PetscClassIdRegister("Discrete System", &PETSCDS_CLASSID);CHKERRQ(ierr);
328022a7a5cSMatthew G. Knepley 
329022a7a5cSMatthew G. Knepley   /* Register Constructors */
3302764a2aaSMatthew G. Knepley   ierr = PetscDSRegisterAll();CHKERRQ(ierr);
331022a7a5cSMatthew G. Knepley   /* Register Events */
332022a7a5cSMatthew G. Knepley   /* Process info exclusions */
333c5929fdfSBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
334022a7a5cSMatthew G. Knepley   if (opt) {
3352764a2aaSMatthew G. Knepley     ierr = PetscStrstr(logList, "ds", &className);CHKERRQ(ierr);
3362764a2aaSMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCDS_CLASSID);CHKERRQ(ierr);}
337022a7a5cSMatthew G. Knepley   }
338022a7a5cSMatthew G. Knepley   /* Process summary exclusions */
3397bf5a629SBarry Smith   ierr = PetscOptionsGetString(NULL,NULL, "-log_exclude", logList, 256, &opt);CHKERRQ(ierr);
340022a7a5cSMatthew G. Knepley   if (opt) {
3412764a2aaSMatthew G. Knepley     ierr = PetscStrstr(logList, "ds", &className);CHKERRQ(ierr);
3422764a2aaSMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCDS_CLASSID);CHKERRQ(ierr);}
343022a7a5cSMatthew G. Knepley   }
3442764a2aaSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscDSFinalizePackage);CHKERRQ(ierr);
345022a7a5cSMatthew G. Knepley   PetscFunctionReturn(0);
346022a7a5cSMatthew G. Knepley }
347e8597998SBarry Smith 
348aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
349e8597998SBarry Smith #undef __FUNCT__
350e8597998SBarry Smith #define __FUNCT__ "PetscDLLibraryRegister_petscdm"
351e8597998SBarry Smith /*
352e8597998SBarry Smith   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
353e8597998SBarry Smith 
354e8597998SBarry Smith   This one registers all the mesh generators and partitioners that are in
355e8597998SBarry Smith   the basic DM library.
356e8597998SBarry Smith 
357e8597998SBarry Smith */
358607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
359e8597998SBarry Smith {
360e8597998SBarry Smith   PetscErrorCode ierr;
361e8597998SBarry Smith 
362e8597998SBarry Smith   PetscFunctionBegin;
363607a6623SBarry Smith   ierr = AOInitializePackage();CHKERRQ(ierr);
364607a6623SBarry Smith   ierr = DMInitializePackage();CHKERRQ(ierr);
36506759e06SMatthew G. Knepley   ierr = PetscFEInitializePackage();CHKERRQ(ierr);
366ab2453f0SMatthew G. Knepley   ierr = PetscFVInitializePackage();CHKERRQ(ierr);
367e8597998SBarry Smith   PetscFunctionReturn(0);
368e8597998SBarry Smith }
369e8597998SBarry Smith 
370aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */
371