Actual source code: slregis.c

  1: #include <petsc/private/characteristicimpl.h>

  3: static PetscBool CharacteristicPackageInitialized = PETSC_FALSE;

  5: /*@C
  6:   CharacteristicFinalizePackage - This function destroys everything in the `Characteristics` package. It is
  7:   called from `PetscFinalize()`.

  9:   Level: developer

 11: .seealso: [](ch_ts), `PetscFinalize()`, `CharacteristicInitializePackage()`
 12: @*/
 13: PetscErrorCode CharacteristicFinalizePackage(void)
 14: {
 15:   PetscFunctionBegin;
 16:   PetscCall(PetscFunctionListDestroy(&CharacteristicList));
 17:   CharacteristicPackageInitialized = PETSC_FALSE;
 18:   CharacteristicRegisterAllCalled  = PETSC_FALSE;
 19:   PetscFunctionReturn(PETSC_SUCCESS);
 20: }

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

 27:   Level: developer

 29: .seealso: [](ch_ts), `PetscInitialize()`, `CharacteristicFinalizePackage()`
 30: @*/
 31: PetscErrorCode CharacteristicInitializePackage(void)
 32: {
 33:   char      logList[256];
 34:   PetscBool opt, pkg;

 36:   PetscFunctionBegin;
 37:   if (CharacteristicPackageInitialized) PetscFunctionReturn(PETSC_SUCCESS);
 38:   CharacteristicPackageInitialized = PETSC_TRUE;
 39:   /* Register Classes */
 40:   PetscCall(PetscClassIdRegister("Method of Characteristics", &CHARACTERISTIC_CLASSID));
 41:   /* Register Constructors */
 42:   PetscCall(CharacteristicRegisterAll());
 43:   /* Register Events */
 44:   PetscCall(PetscLogEventRegister("MOCSetUp", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_SetUp));
 45:   PetscCall(PetscLogEventRegister("MOCSolve", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_Solve));
 46:   PetscCall(PetscLogEventRegister("MOCQueueSetup", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_QueueSetup));
 47:   PetscCall(PetscLogEventRegister("MOCDAUpdate", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_DAUpdate));
 48:   PetscCall(PetscLogEventRegister("MOCHalfTimeLocal", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_HalfTimeLocal));
 49:   PetscCall(PetscLogEventRegister("MOCHalfTimeRemot", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_HalfTimeRemote));
 50:   PetscCall(PetscLogEventRegister("MOCHalfTimeExchg", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_HalfTimeExchange));
 51:   PetscCall(PetscLogEventRegister("MOCFullTimeLocal", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_FullTimeLocal));
 52:   PetscCall(PetscLogEventRegister("MOCFullTimeRemot", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_FullTimeRemote));
 53:   PetscCall(PetscLogEventRegister("MOCFullTimeExchg", CHARACTERISTIC_CLASSID, &CHARACTERISTIC_FullTimeExchange));
 54:   /* Process Info */
 55:   {
 56:     PetscClassId classids[1];

 58:     classids[0] = CHARACTERISTIC_CLASSID;
 59:     PetscCall(PetscInfoProcessClass("characteristic", 1, classids));
 60:   }
 61:   /* Process summary exclusions */
 62:   PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt));
 63:   if (opt) {
 64:     PetscCall(PetscStrInList("characteristic", logList, ',', &pkg));
 65:     if (pkg) PetscCall(PetscLogEventExcludeClass(CHARACTERISTIC_CLASSID));
 66:   }
 67:   /* Process package finalizer */
 68:   PetscCall(PetscRegisterFinalize(CharacteristicFinalizePackage));
 69:   PetscFunctionReturn(PETSC_SUCCESS);
 70: }

 72: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
 73: /*
 74:   PetscDLLibraryRegister - This function is called when the dynamic library it is in is opened.

 76:   This one registers the method of characteristics code
 77:  */
 78: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsccharacteristic(void)
 79: {
 80:   PetscFunctionBegin;
 81:   PetscCall(CharacteristicInitializePackage());
 82:   PetscFunctionReturn(PETSC_SUCCESS);
 83: }

 85: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */