1 2 #include <private/tsimpl.h> 3 4 static PetscBool TSPackageInitialized = PETSC_FALSE; 5 #undef __FUNCT__ 6 #define __FUNCT__ "TSFinalizePackage" 7 /*@C 8 TSFinalizePackage - This function destroys everything in the Petsc interface to Mathematica. It is 9 called from PetscFinalize(). 10 11 Level: developer 12 13 .keywords: Petsc, destroy, package, mathematica 14 .seealso: PetscFinalize() 15 @*/ 16 PetscErrorCode TSFinalizePackage(void) 17 { 18 PetscFunctionBegin; 19 TSPackageInitialized = PETSC_FALSE; 20 TSList = PETSC_NULL; 21 TSRegisterAllCalled = PETSC_FALSE; 22 PetscFunctionReturn(0); 23 } 24 25 #undef __FUNCT__ 26 #define __FUNCT__ "TSInitializePackage" 27 /*@C 28 TSInitializePackage - This function initializes everything in the TS package. It is called 29 from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to TSCreate() 30 when using static libraries. 31 32 Input Parameter: 33 path - The dynamic library path, or PETSC_NULL 34 35 Level: developer 36 37 .keywords: TS, initialize, package 38 .seealso: PetscInitialize() 39 @*/ 40 PetscErrorCode TSInitializePackage(const char path[]) 41 { 42 char logList[256]; 43 char *className; 44 PetscBool opt; 45 PetscErrorCode ierr; 46 47 PetscFunctionBegin; 48 if (TSPackageInitialized) PetscFunctionReturn(0); 49 TSPackageInitialized = PETSC_TRUE; 50 /* Inialize subpackages */ 51 ierr = TSGLInitializePackage(path);CHKERRQ(ierr); 52 ierr = TSARKIMEXInitializePackage(path);CHKERRQ(ierr); 53 ierr = TSGLAdaptInitializePackage(path);CHKERRQ(ierr); 54 /* Register Classes */ 55 ierr = PetscClassIdRegister("TS",&TS_CLASSID);CHKERRQ(ierr); 56 /* Register Constructors */ 57 ierr = TSRegisterAll(path);CHKERRQ(ierr); 58 /* Register Events */ 59 ierr = PetscLogEventRegister("TSStep", TS_CLASSID,&TS_Step);CHKERRQ(ierr); 60 ierr = PetscLogEventRegister("TSPseudoCmptTStp", TS_CLASSID,&TS_PseudoComputeTimeStep);CHKERRQ(ierr); 61 ierr = PetscLogEventRegister("TSFunctionEval", TS_CLASSID,&TS_FunctionEval);CHKERRQ(ierr); 62 ierr = PetscLogEventRegister("TSJacobianEval", TS_CLASSID,&TS_JacobianEval);CHKERRQ(ierr); 63 /* Process info exclusions */ 64 ierr = PetscOptionsGetString(PETSC_NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr); 65 if (opt) { 66 ierr = PetscStrstr(logList, "ts", &className);CHKERRQ(ierr); 67 if (className) { 68 ierr = PetscInfoDeactivateClass(TS_CLASSID);CHKERRQ(ierr); 69 } 70 } 71 /* Process summary exclusions */ 72 ierr = PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);CHKERRQ(ierr); 73 if (opt) { 74 ierr = PetscStrstr(logList, "ts", &className);CHKERRQ(ierr); 75 if (className) { 76 ierr = PetscLogEventDeactivateClass(TS_CLASSID);CHKERRQ(ierr); 77 } 78 } 79 ierr = PetscRegisterFinalize(TSFinalizePackage);CHKERRQ(ierr); 80 PetscFunctionReturn(0); 81 } 82 83 #ifdef PETSC_USE_DYNAMIC_LIBRARIES 84 EXTERN_C_BEGIN 85 #undef __FUNCT__ 86 #define __FUNCT__ "PetscDLLibraryRegister_petscts" 87 /* 88 PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened. 89 90 This one registers all the TS methods that are in the basic PETSc libpetscts library. 91 92 Input Parameter: 93 path - library path 94 */ 95 PetscErrorCode PetscDLLibraryRegister_petscts(const char path[]) 96 { 97 PetscErrorCode ierr; 98 99 PetscFunctionBegin; 100 ierr = TSInitializePackage(path);CHKERRQ(ierr); 101 PetscFunctionReturn(0); 102 } 103 EXTERN_C_END 104 105 106 #endif /* PETSC_USE_DYNAMIC_LIBRARIES */ 107