Actual source code: dlregists.c
1: #include <petsc/private/tsimpl.h>
3: static PetscBool TSPackageInitialized = PETSC_FALSE;
4: /*@C
5: TSFinalizePackage - This function destroys everything in the Petsc interface to `TS`. It is
6: called from `PetscFinalize()`.
8: Level: developer
10: .seealso: [](ch_ts), `TS`, `PetscFinalize()`, `TSInitializePackage()`
11: @*/
12: PetscErrorCode TSFinalizePackage(void)
13: {
14: PetscFunctionBegin;
15: PetscCall(PetscFunctionListDestroy(&TSList));
16: PetscCall(PetscFunctionListDestroy(&TSTrajectoryList));
17: TSPackageInitialized = PETSC_FALSE;
18: TSRegisterAllCalled = PETSC_FALSE;
19: PetscFunctionReturn(PETSC_SUCCESS);
20: }
22: /*@C
23: TSInitializePackage - This function initializes everything in the `TS` package. It is called
24: from `PetscDLLibraryRegister_petscts()` when using dynamic libraries, and on the first call to `TSCreate()`
25: when using shared or static libraries.
27: Level: developer
29: .seealso: [](ch_ts), `TS`, `PetscInitialize()`, `TSFinalizePackage()`
30: @*/
31: PetscErrorCode TSInitializePackage(void)
32: {
33: char logList[256];
34: PetscBool opt, pkg, cls;
36: PetscFunctionBegin;
37: if (TSPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
38: TSPackageInitialized = PETSC_TRUE;
39: /* Initialize subpackages */
40: PetscCall(TSAdaptInitializePackage());
41: PetscCall(TSGLLEInitializePackage());
42: PetscCall(TSRKInitializePackage());
43: PetscCall(TSGLEEInitializePackage());
44: PetscCall(TSARKIMEXInitializePackage());
45: PetscCall(TSRosWInitializePackage());
46: PetscCall(TSSSPInitializePackage());
47: PetscCall(TSGLLEAdaptInitializePackage());
48: PetscCall(TSBasicSymplecticInitializePackage());
49: /* Register Classes */
50: PetscCall(PetscClassIdRegister("TS", &TS_CLASSID));
51: PetscCall(PetscClassIdRegister("DMTS", &DMTS_CLASSID));
52: PetscCall(PetscClassIdRegister("TSTrajectory", &TSTRAJECTORY_CLASSID));
54: /* Register Constructors */
55: PetscCall(TSRegisterAll());
56: PetscCall(TSTrajectoryRegisterAll());
57: /* Register Events */
58: PetscCall(PetscLogEventRegister("TSStep", TS_CLASSID, &TS_Step));
59: PetscCall(PetscLogEventRegister("TSFunctionEval", TS_CLASSID, &TS_FunctionEval));
60: PetscCall(PetscLogEventRegister("TSJacobianEval", TS_CLASSID, &TS_JacobianEval));
61: PetscCall(PetscLogEventRegister("TSForwardStep", TS_CLASSID, &TS_ForwardStep));
62: PetscCall(PetscLogEventRegister("TSAdjointStep", TS_CLASSID, &TS_AdjointStep));
63: PetscCall(PetscLogEventRegister("TSTrajectorySet", TSTRAJECTORY_CLASSID, &TSTrajectory_Set));
64: PetscCall(PetscLogEventRegister("TSTrajectoryGet", TSTRAJECTORY_CLASSID, &TSTrajectory_Get));
65: PetscCall(PetscLogEventRegister("TSTrajGetVecs", TSTRAJECTORY_CLASSID, &TSTrajectory_GetVecs));
66: PetscCall(PetscLogEventRegister("TSTrajSetUp", TSTRAJECTORY_CLASSID, &TSTrajectory_SetUp));
67: PetscCall(PetscLogEventRegister("TSTrajDiskWrite", TSTRAJECTORY_CLASSID, &TSTrajectory_DiskWrite));
68: PetscCall(PetscLogEventRegister("TSTrajDiskRead", TSTRAJECTORY_CLASSID, &TSTrajectory_DiskRead));
69: PetscCall(PetscLogEventRegister("TSPseudoCmptTStp", TS_CLASSID, &TS_PseudoComputeTimeStep));
70: /* Process Info */
71: {
72: PetscClassId classids[4];
74: classids[0] = TS_CLASSID;
75: classids[1] = DMTS_CLASSID;
76: classids[2] = TSADAPT_CLASSID;
77: classids[3] = TSTRAJECTORY_CLASSID;
78: PetscCall(PetscInfoProcessClass("ts", 1, classids));
79: PetscCall(PetscInfoProcessClass("dm", 1, &classids[1]));
80: PetscCall(PetscInfoProcessClass("tsadapt", 1, &classids[2]));
81: PetscCall(PetscInfoProcessClass("tstrajectory", 1, &classids[3]));
82: }
83: /* Process summary exclusions */
84: PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
85: if (opt) {
86: PetscCall(PetscStrInList("ts", logList, ',', &pkg));
87: if (pkg) PetscCall(PetscLogEventExcludeClass(TS_CLASSID));
88: PetscCall(PetscStrInList("dm", logList, ',', &cls));
89: if (pkg || cls) PetscCall(PetscLogEventExcludeClass(DMTS_CLASSID));
90: PetscCall(PetscStrInList("tsadapt", logList, ',', &cls));
91: if (pkg || cls) PetscCall(PetscLogEventExcludeClass(TSADAPT_CLASSID));
92: PetscCall(PetscStrInList("tstrajectory", logList, ',', &cls));
93: if (pkg || cls) PetscCall(PetscLogEventExcludeClass(TSTRAJECTORY_CLASSID));
94: }
95: /* Register package finalizer */
96: PetscCall(PetscRegisterFinalize(TSFinalizePackage));
97: PetscFunctionReturn(PETSC_SUCCESS);
98: }
100: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
101: /*
102: PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.
104: This one registers all the TS methods that are in the basic PETSc libpetscts library.
106: */
107: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); /*prototype*/
108: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void)
109: {
110: PetscFunctionBegin;
111: PetscCall(TSInitializePackage());
112: PetscFunctionReturn(PETSC_SUCCESS);
113: }
114: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */