xref: /petsc/src/dm/interface/dlregisdmdm.c (revision f62f30fa0b604065edcb2417b3a12321a0b1b7ee)
1e8597998SBarry Smith 
24035e84dSBarry Smith #include <petsc-private/dmdaimpl.h>
334541f0dSBarry Smith #include <petsc-private/dmpleximpl.h>
4e8597998SBarry Smith 
5e8597998SBarry Smith static PetscBool DMPackageInitialized = PETSC_FALSE;
6e8597998SBarry Smith #undef __FUNCT__
7e8597998SBarry Smith #define __FUNCT__ "DMFinalizePackage"
8e8597998SBarry Smith /*@C
9e8597998SBarry Smith   DMFinalizePackage - This function finalizes everything in the DM package. It is called
10e8597998SBarry Smith   from PetscFinalize().
11e8597998SBarry Smith 
12e8597998SBarry Smith   Level: developer
13e8597998SBarry Smith 
14e8597998SBarry Smith .keywords: AO, initialize, package
15e8597998SBarry Smith .seealso: PetscInitialize()
16e8597998SBarry Smith @*/
17e8597998SBarry Smith PetscErrorCode  DMFinalizePackage(void)
18e8597998SBarry Smith {
19e8597998SBarry Smith   PetscErrorCode ierr;
20e8597998SBarry Smith 
21e8597998SBarry Smith   PetscFunctionBegin;
2237e93019SBarry Smith   ierr = PetscFunctionListDestroy(&DMList);CHKERRQ(ierr);
23e8597998SBarry Smith   DMPackageInitialized = PETSC_FALSE;
24e8597998SBarry Smith   DMRegisterAllCalled  = PETSC_FALSE;
25e8597998SBarry Smith   PetscFunctionReturn(0);
26e8597998SBarry Smith }
27e8597998SBarry Smith 
28e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
298cc058d9SJed Brown PETSC_EXTERN PetscErrorCode MatCreate_HYPREStruct(Mat);
30e8597998SBarry Smith #endif
31e8597998SBarry Smith 
32e8597998SBarry Smith #undef __FUNCT__
33e8597998SBarry Smith #define __FUNCT__ "DMInitializePackage"
34e8597998SBarry Smith /*@C
35e8597998SBarry Smith   DMInitializePackage - This function initializes everything in the DM package. It is called
36e8597998SBarry Smith   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to AOCreate()
37e8597998SBarry Smith   or DMDACreate() when using static libraries.
38e8597998SBarry Smith 
39e8597998SBarry Smith   Level: developer
40e8597998SBarry Smith 
41e8597998SBarry Smith .keywords: AO, initialize, package
42e8597998SBarry Smith .seealso: PetscInitialize()
43e8597998SBarry Smith @*/
44607a6623SBarry Smith PetscErrorCode  DMInitializePackage(void)
45e8597998SBarry Smith {
46e8597998SBarry Smith   char           logList[256];
47e8597998SBarry Smith   char           *className;
48e8597998SBarry Smith   PetscBool      opt;
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);
57e8597998SBarry Smith 
58e8597998SBarry Smith #if defined(PETSC_HAVE_HYPRE)
59bdf89e91SBarry Smith   ierr = MatRegister(MATHYPRESTRUCT, MatCreate_HYPREStruct);CHKERRQ(ierr);
60e8597998SBarry Smith #endif
61e8597998SBarry Smith 
62e8597998SBarry Smith   /* Register Constructors */
63607a6623SBarry Smith   ierr = DMRegisterAll();CHKERRQ(ierr);
64e8597998SBarry Smith   /* Register Events */
65e8597998SBarry Smith   ierr = PetscLogEventRegister("DMConvert",              DM_CLASSID,&DM_Convert);CHKERRQ(ierr);
66e8597998SBarry Smith   ierr = PetscLogEventRegister("DMGlobalToLocal",        DM_CLASSID,&DM_GlobalToLocal);CHKERRQ(ierr);
67e8597998SBarry Smith   ierr = PetscLogEventRegister("DMLocalToGlobal",        DM_CLASSID,&DM_LocalToGlobal);CHKERRQ(ierr);
68e8597998SBarry Smith 
69e8597998SBarry Smith   ierr = PetscLogEventRegister("DMDALocalADFunc",        DM_CLASSID,&DMDA_LocalADFunction);CHKERRQ(ierr);
70e8597998SBarry Smith 
71a72f3261SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexInterpolate",      DM_CLASSID,&DMPLEX_Interpolate);CHKERRQ(ierr);
72b96ba592SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexPartition",        DM_CLASSID,&DMPLEX_Partition);CHKERRQ(ierr);
73e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexDistribute",       DM_CLASSID,&DMPLEX_Distribute);CHKERRQ(ierr);
745d95960aSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribCones",     DM_CLASSID,&DMPLEX_DistributeCones);CHKERRQ(ierr);
751337e6e5SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribLabels",    DM_CLASSID,&DMPLEX_DistributeLabels);CHKERRQ(ierr);
761337e6e5SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribSF",        DM_CLASSID,&DMPLEX_DistributeSF);CHKERRQ(ierr);
775d95960aSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribField",     DM_CLASSID,&DMPLEX_DistributeField);CHKERRQ(ierr);
785d95960aSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexDistribData",      DM_CLASSID,&DMPLEX_DistributeData);CHKERRQ(ierr);
79e8597998SBarry Smith   ierr = PetscLogEventRegister("DMPlexStratify",         DM_CLASSID,&DMPLEX_Stratify);CHKERRQ(ierr);
80a72f3261SMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexPreallocate",      DM_CLASSID,&DMPLEX_Preallocate);CHKERRQ(ierr);
81a0845e3aSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexResidualFEM",      DM_CLASSID,&DMPLEX_ResidualFEM);CHKERRQ(ierr);
82a319912fSMatthew G. Knepley   ierr = PetscLogEventRegister("DMPlexJacobianFEM",      DM_CLASSID,&DMPLEX_JacobianFEM);CHKERRQ(ierr);
83e8597998SBarry Smith   /* Process info exclusions */
84e8597998SBarry Smith   ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
85e8597998SBarry Smith   if (opt) {
86e8597998SBarry Smith     ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr);
87e8597998SBarry Smith     if (className) {
88e8597998SBarry Smith       ierr = PetscInfoDeactivateClass(DM_CLASSID);CHKERRQ(ierr);
89e8597998SBarry Smith     }
90e8597998SBarry Smith   }
91e8597998SBarry Smith   /* Process summary exclusions */
92e8597998SBarry Smith   ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
93e8597998SBarry Smith   if (opt) {
94e8597998SBarry Smith     ierr = PetscStrstr(logList, "da", &className);CHKERRQ(ierr);
95e8597998SBarry Smith     if (className) {
96e8597998SBarry Smith       ierr = PetscLogEventDeactivateClass(DM_CLASSID);CHKERRQ(ierr);
97e8597998SBarry Smith     }
98e8597998SBarry Smith   }
99e8597998SBarry Smith   ierr = PetscRegisterFinalize(DMFinalizePackage);CHKERRQ(ierr);
100e8597998SBarry Smith   PetscFunctionReturn(0);
101e8597998SBarry Smith }
10206759e06SMatthew G. Knepley #include <petscfe.h>
103e8597998SBarry Smith 
10406759e06SMatthew G. Knepley static PetscBool PetscFEPackageInitialized = PETSC_FALSE;
10506759e06SMatthew G. Knepley #undef __FUNCT__
10606759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEFinalizePackage"
10706759e06SMatthew G. Knepley /*@C
10806759e06SMatthew G. Knepley   PetscFEFinalizePackage - This function finalizes everything in the PetscFE package. It is called
10906759e06SMatthew G. Knepley   from PetscFinalize().
110e8597998SBarry Smith 
11106759e06SMatthew G. Knepley   Level: developer
11206759e06SMatthew G. Knepley 
11306759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package
11406759e06SMatthew G. Knepley .seealso: PetscInitialize()
11506759e06SMatthew G. Knepley @*/
11606759e06SMatthew G. Knepley PetscErrorCode PetscFEFinalizePackage(void)
11706759e06SMatthew G. Knepley {
11806759e06SMatthew G. Knepley   PetscErrorCode ierr;
11906759e06SMatthew G. Knepley 
12006759e06SMatthew G. Knepley   PetscFunctionBegin;
12106759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscSpaceList);CHKERRQ(ierr);
12206759e06SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscDualSpaceList);CHKERRQ(ierr);
1230483ade4SMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFEList);CHKERRQ(ierr);
12406759e06SMatthew G. Knepley   PetscFEPackageInitialized       = PETSC_FALSE;
12506759e06SMatthew G. Knepley   PetscSpaceRegisterAllCalled     = PETSC_FALSE;
12606759e06SMatthew G. Knepley   PetscDualSpaceRegisterAllCalled = PETSC_FALSE;
1270483ade4SMatthew G. Knepley   PetscFERegisterAllCalled        = PETSC_FALSE;
12806759e06SMatthew G. Knepley   PetscFunctionReturn(0);
12906759e06SMatthew G. Knepley }
13006759e06SMatthew G. Knepley 
13106759e06SMatthew G. Knepley #undef __FUNCT__
13206759e06SMatthew G. Knepley #define __FUNCT__ "PetscFEInitializePackage"
13306759e06SMatthew G. Knepley /*@C
13406759e06SMatthew G. Knepley   PetscFEInitializePackage - This function initializes everything in the FE package. It is called
13506759e06SMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscSpaceCreate()
13606759e06SMatthew G. Knepley   when using static libraries.
13706759e06SMatthew G. Knepley 
13806759e06SMatthew G. Knepley   Level: developer
13906759e06SMatthew G. Knepley 
14006759e06SMatthew G. Knepley .keywords: PetscFE, initialize, package
14106759e06SMatthew G. Knepley .seealso: PetscInitialize()
14206759e06SMatthew G. Knepley @*/
14306759e06SMatthew G. Knepley PetscErrorCode PetscFEInitializePackage(void)
14406759e06SMatthew G. Knepley {
14506759e06SMatthew G. Knepley   char           logList[256];
14606759e06SMatthew G. Knepley   char          *className;
14706759e06SMatthew G. Knepley   PetscBool      opt;
14806759e06SMatthew G. Knepley   PetscErrorCode ierr;
14906759e06SMatthew G. Knepley 
15006759e06SMatthew G. Knepley   PetscFunctionBegin;
15106759e06SMatthew G. Knepley   if (PetscFEPackageInitialized) PetscFunctionReturn(0);
15206759e06SMatthew G. Knepley   PetscFEPackageInitialized = PETSC_TRUE;
15306759e06SMatthew G. Knepley 
15406759e06SMatthew G. Knepley   /* Register Classes */
15506759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Linear Space", &PETSCSPACE_CLASSID);CHKERRQ(ierr);
15606759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("Dual Space",   &PETSCDUALSPACE_CLASSID);CHKERRQ(ierr);
15706759e06SMatthew G. Knepley   ierr = PetscClassIdRegister("FE Space",     &PETSCFE_CLASSID);CHKERRQ(ierr);
15806759e06SMatthew G. Knepley 
15906759e06SMatthew G. Knepley   /* Register Constructors */
16006759e06SMatthew G. Knepley   ierr = PetscSpaceRegisterAll();CHKERRQ(ierr);
1610483ade4SMatthew G. Knepley   ierr = PetscDualSpaceRegisterAll();CHKERRQ(ierr);
1620483ade4SMatthew G. Knepley   ierr = PetscFERegisterAll();CHKERRQ(ierr);
16306759e06SMatthew G. Knepley   /* Register Events */
16406759e06SMatthew G. Knepley   /* Process info exclusions */
16506759e06SMatthew G. Knepley   ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
16606759e06SMatthew G. Knepley   if (opt) {
16706759e06SMatthew G. Knepley     ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr);
168*f62f30faSMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
16906759e06SMatthew G. Knepley   }
17006759e06SMatthew G. Knepley   /* Process summary exclusions */
17106759e06SMatthew G. Knepley   ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
17206759e06SMatthew G. Knepley   if (opt) {
173*f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fe", &className);CHKERRQ(ierr);
174*f62f30faSMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCFE_CLASSID);CHKERRQ(ierr);}
17506759e06SMatthew G. Knepley   }
17606759e06SMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFEFinalizePackage);CHKERRQ(ierr);
17706759e06SMatthew G. Knepley   PetscFunctionReturn(0);
17806759e06SMatthew G. Knepley }
179*f62f30faSMatthew G. Knepley #include <petscfv.h>
180*f62f30faSMatthew G. Knepley 
181*f62f30faSMatthew G. Knepley static PetscBool PetscFVPackageInitialized = PETSC_FALSE;
182*f62f30faSMatthew G. Knepley #undef __FUNCT__
183*f62f30faSMatthew G. Knepley #define __FUNCT__ "PetscFVFinalizePackage"
184*f62f30faSMatthew G. Knepley /*@C
185*f62f30faSMatthew G. Knepley   PetscFVFinalizePackage - This function finalizes everything in the PetscFV package. It is called
186*f62f30faSMatthew G. Knepley   from PetscFinalize().
187*f62f30faSMatthew G. Knepley 
188*f62f30faSMatthew G. Knepley   Level: developer
189*f62f30faSMatthew G. Knepley 
190*f62f30faSMatthew G. Knepley .keywords: PetscFV, initialize, package
191*f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
192*f62f30faSMatthew G. Knepley @*/
193*f62f30faSMatthew G. Knepley PetscErrorCode PetscFVFinalizePackage(void)
194*f62f30faSMatthew G. Knepley {
195*f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
196*f62f30faSMatthew G. Knepley 
197*f62f30faSMatthew G. Knepley   PetscFunctionBegin;
198*f62f30faSMatthew G. Knepley   ierr = PetscFunctionListDestroy(&PetscFVList);CHKERRQ(ierr);
199*f62f30faSMatthew G. Knepley   PetscFVPackageInitialized = PETSC_FALSE;
200*f62f30faSMatthew G. Knepley   PetscFVRegisterAllCalled  = PETSC_FALSE;
201*f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
202*f62f30faSMatthew G. Knepley }
203*f62f30faSMatthew G. Knepley 
204*f62f30faSMatthew G. Knepley #undef __FUNCT__
205*f62f30faSMatthew G. Knepley #define __FUNCT__ "PetscFVInitializePackage"
206*f62f30faSMatthew G. Knepley /*@C
207*f62f30faSMatthew G. Knepley   PetscFVInitializePackage - This function initializes everything in the FV package. It is called
208*f62f30faSMatthew G. Knepley   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscFVCreate()
209*f62f30faSMatthew G. Knepley   when using static libraries.
210*f62f30faSMatthew G. Knepley 
211*f62f30faSMatthew G. Knepley   Level: developer
212*f62f30faSMatthew G. Knepley 
213*f62f30faSMatthew G. Knepley .keywords: PetscFV, initialize, package
214*f62f30faSMatthew G. Knepley .seealso: PetscInitialize()
215*f62f30faSMatthew G. Knepley @*/
216*f62f30faSMatthew G. Knepley PetscErrorCode PetscFVInitializePackage(void)
217*f62f30faSMatthew G. Knepley {
218*f62f30faSMatthew G. Knepley   char           logList[256];
219*f62f30faSMatthew G. Knepley   char          *className;
220*f62f30faSMatthew G. Knepley   PetscBool      opt;
221*f62f30faSMatthew G. Knepley   PetscErrorCode ierr;
222*f62f30faSMatthew G. Knepley 
223*f62f30faSMatthew G. Knepley   PetscFunctionBegin;
224*f62f30faSMatthew G. Knepley   if (PetscFVPackageInitialized) PetscFunctionReturn(0);
225*f62f30faSMatthew G. Knepley   PetscFVPackageInitialized = PETSC_TRUE;
226*f62f30faSMatthew G. Knepley 
227*f62f30faSMatthew G. Knepley   /* Register Classes */
228*f62f30faSMatthew G. Knepley   ierr = PetscClassIdRegister("FV Space", &PETSCFV_CLASSID);CHKERRQ(ierr);
229*f62f30faSMatthew G. Knepley 
230*f62f30faSMatthew G. Knepley   /* Register Constructors */
231*f62f30faSMatthew G. Knepley   ierr = PetscFVRegisterAll();CHKERRQ(ierr);
232*f62f30faSMatthew G. Knepley   /* Register Events */
233*f62f30faSMatthew G. Knepley   /* Process info exclusions */
234*f62f30faSMatthew G. Knepley   ierr = PetscOptionsGetString(NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
235*f62f30faSMatthew G. Knepley   if (opt) {
236*f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fv", &className);CHKERRQ(ierr);
237*f62f30faSMatthew G. Knepley     if (className) {ierr = PetscInfoDeactivateClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
238*f62f30faSMatthew G. Knepley   }
239*f62f30faSMatthew G. Knepley   /* Process summary exclusions */
240*f62f30faSMatthew G. Knepley   ierr = PetscOptionsGetString(NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr);
241*f62f30faSMatthew G. Knepley   if (opt) {
242*f62f30faSMatthew G. Knepley     ierr = PetscStrstr(logList, "fv", &className);CHKERRQ(ierr);
243*f62f30faSMatthew G. Knepley     if (className) {ierr = PetscLogEventDeactivateClass(PETSCFV_CLASSID);CHKERRQ(ierr);}
244*f62f30faSMatthew G. Knepley   }
245*f62f30faSMatthew G. Knepley   ierr = PetscRegisterFinalize(PetscFVFinalizePackage);CHKERRQ(ierr);
246*f62f30faSMatthew G. Knepley   PetscFunctionReturn(0);
247*f62f30faSMatthew G. Knepley }
248e8597998SBarry Smith 
249aa2d57e9SJed Brown #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
250e8597998SBarry Smith #undef __FUNCT__
251e8597998SBarry Smith #define __FUNCT__ "PetscDLLibraryRegister_petscdm"
252e8597998SBarry Smith /*
253e8597998SBarry Smith   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
254e8597998SBarry Smith 
255e8597998SBarry Smith   This one registers all the mesh generators and partitioners that are in
256e8597998SBarry Smith   the basic DM library.
257e8597998SBarry Smith 
258e8597998SBarry Smith */
259607a6623SBarry Smith PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscdm(void)
260e8597998SBarry Smith {
261e8597998SBarry Smith   PetscErrorCode ierr;
262e8597998SBarry Smith 
263e8597998SBarry Smith   PetscFunctionBegin;
264607a6623SBarry Smith   ierr = AOInitializePackage();CHKERRQ(ierr);
265607a6623SBarry Smith   ierr = DMInitializePackage();CHKERRQ(ierr);
26606759e06SMatthew G. Knepley   ierr = PetscFEInitializePackage();CHKERRQ(ierr);
267e8597998SBarry Smith   PetscFunctionReturn(0);
268e8597998SBarry Smith }
269e8597998SBarry Smith 
270aa2d57e9SJed Brown #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */
271