Actual source code: slregis.c

petsc-3.3-p7 2013-05-11
  1: #include <petsc-private/characteristicimpl.h>

  3: static PetscBool  CharacteristicPackageInitialized = PETSC_FALSE;
  6: /*@C
  7:   CharacteristicFinalizePackage - This function destroys everything in the Petsc interface to the characteristics package. It is
  8:   called from PetscFinalize().

 10:   Level: developer

 12: .keywords: Petsc, destroy, package, mathematica
 13: .seealso: PetscFinalize()
 14: @*/
 15: PetscErrorCode CharacteristicFinalizePackage(void)
 16: {
 18:   CharacteristicPackageInitialized = PETSC_FALSE;
 19:   CharacteristicRegisterAllCalled = PETSC_FALSE;
 20:   CharacteristicList              = PETSC_NULL;
 21:   return(0);
 22: }

 26: /*@C
 27:   CharacteristicInitializePackage - This function initializes everything in the Characteristic package. It is called
 28:   from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to CharacteristicCreate()
 29:   when using static libraries.

 31:   Input Parameter:
 32:   path - The dynamic library path, or PETSC_NULL

 34:   Level: developer

 36: .keywords: Characteristic, initialize, package
 37: .seealso: PetscInitialize()
 38: @*/
 39: PetscErrorCode CharacteristicInitializePackage(const char path[])
 40: {
 41:   char              logList[256];
 42:   char             *className;
 43:   PetscBool         opt;
 44:   PetscErrorCode    ierr;

 47:   if (CharacteristicPackageInitialized) return(0);
 48:   CharacteristicPackageInitialized = PETSC_TRUE;
 49:   /* Register Classes */
 50:   PetscClassIdRegister("Method of Characteristics",&CHARACTERISTIC_CLASSID);
 51:   /* Register Constructors */
 52:   CharacteristicRegisterAll(path);
 53:   /* Register Events */
 54:   PetscLogEventRegister("MOCSetUp",         CHARACTERISTIC_CLASSID,&CHARACTERISTIC_SetUp);
 55:   PetscLogEventRegister("MOCSolve",         CHARACTERISTIC_CLASSID,&CHARACTERISTIC_Solve);
 56:   PetscLogEventRegister("MOCQueueSetup",    CHARACTERISTIC_CLASSID,&CHARACTERISTIC_QueueSetup);
 57:   PetscLogEventRegister("MOCDAUpdate",      CHARACTERISTIC_CLASSID,&CHARACTERISTIC_DAUpdate);
 58:   PetscLogEventRegister("MOCHalfTimeLocal", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_HalfTimeLocal);
 59:   PetscLogEventRegister("MOCHalfTimeRemot", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_HalfTimeRemote);
 60:   PetscLogEventRegister("MOCHalfTimeExchg", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_HalfTimeExchange);
 61:   PetscLogEventRegister("MOCFullTimeLocal", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_FullTimeLocal);
 62:   PetscLogEventRegister("MOCFullTimeRemot", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_FullTimeRemote);
 63:   PetscLogEventRegister("MOCFullTimeExchg", CHARACTERISTIC_CLASSID,&CHARACTERISTIC_FullTimeExchange);
 64:   /* Process info exclusions */
 65:   PetscOptionsGetString(PETSC_NULL, "-log_info_exclude", logList, 256, &opt);
 66:   if (opt) {
 67:     PetscStrstr(logList, "characteristic", &className);
 68:     if (className) {
 69:       PetscInfoDeactivateClass(CHARACTERISTIC_CLASSID);
 70:     }
 71:   }
 72:   /* Process summary exclusions */
 73:   PetscOptionsGetString(PETSC_NULL, "-log_summary_exclude", logList, 256, &opt);
 74:   if (opt) {
 75:     PetscStrstr(logList, "characteristic", &className);
 76:     if (className) {
 77:       PetscLogEventDeactivateClass(CHARACTERISTIC_CLASSID);
 78:     }
 79:   }
 80:   PetscRegisterFinalize(CharacteristicFinalizePackage);
 81:   return(0);
 82: }

 84: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
 85: EXTERN_C_BEGIN
 88: /*
 89:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

 91:   This one registers the method of characteristics code

 93:   Input Parameter:
 94:   path - library path
 95:  */
 96: PetscErrorCode PetscDLLibraryRegister_petsccharacteristic(const char path[])
 97: {

101:   CharacteristicInitializePackage(path);
102:   return(0);
103: }
104: EXTERN_C_END

106: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */