Date: 2022-03-31T04:48:40+00:00

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 Mathematica. It is
      6:   called from PetscFinalize().

      8:   Level: developer

     10: .seealso: PetscFinalize()
     11: @*/
     12: PetscErrorCode  TSFinalizePackage(void)
     13: {
     14:   PetscFunctionListDestroy(&TSList);
     15:   PetscFunctionListDestroy(&TSTrajectoryList);
     16:   TSPackageInitialized = PETSC_FALSE;
     17:   TSRegisterAllCalled  = PETSC_FALSE;
     18:   return 0;
     19: }

     21: /*@C
     22:   TSInitializePackage - This function initializes everything in the TS package. It is called
     23:   from PetscDLLibraryRegister_petscts() when using dynamic libraries, and on the first call to TSCreate()
     24:   when using shared or static libraries.

     26:   Level: developer

     28: .seealso: PetscInitialize()
     29: @*/
     30: PetscErrorCode  TSInitializePackage(void)
     31: {
     32:   char           logList[256];
     33:   PetscBool      opt,pkg,cls;

     35:   if (TSPackageInitialized) return 0;
     36:   TSPackageInitialized = PETSC_TRUE;
     37:   /* Inialize subpackages */
     38:   TSAdaptInitializePackage();
     39:   TSGLLEInitializePackage();
     40:   TSRKInitializePackage();
     41:   TSGLEEInitializePackage();
     42:   TSARKIMEXInitializePackage();
     43:   TSRosWInitializePackage();
     44:   TSSSPInitializePackage();
     45:   TSGLLEAdaptInitializePackage();
     46:   TSBasicSymplecticInitializePackage();
     47:   /* Register Classes */
     48:   PetscClassIdRegister("TS",&TS_CLASSID);
     49:   PetscClassIdRegister("DMTS",&DMTS_CLASSID);
     50:   PetscClassIdRegister("TSTrajectory",&TSTRAJECTORY_CLASSID);

     52:   /* Register Constructors */
     53:   TSRegisterAll();
     54:   TSTrajectoryRegisterAll();
     55:   /* Register Events */
     56:   PetscLogEventRegister("TSStep",          TS_CLASSID,&TS_Step);
     57:   PetscLogEventRegister("TSFunctionEval",  TS_CLASSID,&TS_FunctionEval);
     58:   PetscLogEventRegister("TSJacobianEval",  TS_CLASSID,&TS_JacobianEval);
     59:   PetscLogEventRegister("TSForwardStep",   TS_CLASSID,&TS_ForwardStep);
     60:   PetscLogEventRegister("TSAdjointStep",   TS_CLASSID,&TS_AdjointStep);
     61:   PetscLogEventRegister("TSTrajectorySet", TSTRAJECTORY_CLASSID,&TSTrajectory_Set);
     62:   PetscLogEventRegister("TSTrajectoryGet", TSTRAJECTORY_CLASSID,&TSTrajectory_Get);
     63:   PetscLogEventRegister("TSTrajGetVecs",   TSTRAJECTORY_CLASSID,&TSTrajectory_GetVecs);
     64:   PetscLogEventRegister("TSTrajSetUp", TSTRAJECTORY_CLASSID,&TSTrajectory_SetUp);
     65:   PetscLogEventRegister("TSTrajDiskWrite", TSTRAJECTORY_CLASSID,&TSTrajectory_DiskWrite);
     66:   PetscLogEventRegister("TSTrajDiskRead",  TSTRAJECTORY_CLASSID,&TSTrajectory_DiskRead);
     67:   PetscLogEventRegister("TSPseudoCmptTStp",TS_CLASSID,&TS_PseudoComputeTimeStep);
     68:   /* Process Info */
     69:   {
     70:     PetscClassId  classids[4];

     72:     classids[0] = TS_CLASSID;
     73:     classids[1] = DMTS_CLASSID;
     74:     classids[2] = TSADAPT_CLASSID;
     75:     classids[3] = TSTRAJECTORY_CLASSID;
     76:     PetscInfoProcessClass("ts", 1, classids);
     77:     PetscInfoProcessClass("dm", 1, &classids[1]);
     78:     PetscInfoProcessClass("tsadapt", 1, &classids[2]);
     79:     PetscInfoProcessClass("tstrajectory", 1, &classids[3]);
     80:   }
     81:   /* Process summary exclusions */
     82:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
     83:   if (opt) {
     84:     PetscStrInList("ts",logList,',',&pkg);
     85:     if (pkg) PetscLogEventExcludeClass(TS_CLASSID);
     86:     PetscStrInList("dm",logList,',',&cls);
     87:     if (pkg || cls) PetscLogEventExcludeClass(DMTS_CLASSID);
     88:     PetscStrInList("tsadapt",logList,',',&cls);
     89:     if (pkg || cls) PetscLogEventExcludeClass(TSADAPT_CLASSID);
     90:     PetscStrInList("tstrajectory",logList,',',&cls);
     91:     if (pkg || cls) PetscLogEventExcludeClass(TSTRAJECTORY_CLASSID);
     92:   }
     93:   /* Register package finalizer */
     94:   PetscRegisterFinalize(TSFinalizePackage);
     95:   return 0;
     96: }

     98: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
     99: /*
    100:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

    102:   This one registers all the TS methods that are in the basic PETSc libpetscts library.

    104:  */
    105: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void); /*prototype*/
    106: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscts(void)
    107: {
    108:   TSInitializePackage();
    109:   return 0;
    110: }
    111: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */