1 2 #include <petsc/private/randomimpl.h> 3 4 static PetscBool PetscRandomPackageInitialized = PETSC_FALSE; 5 /*@C 6 PetscRandomFinalizePackage - This function destroys everything in the Petsc interface to the Random package. It is 7 called from PetscFinalize(). 8 9 Level: developer 10 11 .seealso: `PetscFinalize()` 12 @*/ 13 PetscErrorCode PetscRandomFinalizePackage(void) { 14 PetscFunctionBegin; 15 PetscCall(PetscFunctionListDestroy(&PetscRandomList)); 16 PetscRandomPackageInitialized = PETSC_FALSE; 17 PetscRandomRegisterAllCalled = PETSC_FALSE; 18 PetscFunctionReturn(0); 19 } 20 21 /*@C 22 PetscRandomInitializePackage - This function initializes everything in the PetscRandom package. It is called 23 from PetscDLLibraryRegister_petsc() when using dynamic libraries, and on the first call to PetscRandomCreate() 24 when using shared or static libraries. 25 26 Level: developer 27 28 .seealso: `PetscInitialize()` 29 @*/ 30 PetscErrorCode PetscRandomInitializePackage(void) { 31 char logList[256]; 32 PetscBool opt, pkg; 33 34 PetscFunctionBegin; 35 if (PetscRandomPackageInitialized) PetscFunctionReturn(0); 36 PetscRandomPackageInitialized = PETSC_TRUE; 37 /* Register Class */ 38 PetscCall(PetscClassIdRegister("PetscRandom", &PETSC_RANDOM_CLASSID)); 39 /* Register Constructors */ 40 PetscCall(PetscRandomRegisterAll()); 41 /* Process Info */ 42 { 43 PetscClassId classids[1]; 44 45 classids[0] = PETSC_RANDOM_CLASSID; 46 PetscCall(PetscInfoProcessClass("random", 1, classids)); 47 } 48 /* Process summary exclusions */ 49 PetscCall(PetscOptionsGetString(NULL, NULL, "-log_exclude", logList, sizeof(logList), &opt)); 50 if (opt) { 51 PetscCall(PetscStrInList("random", logList, ',', &pkg)); 52 if (pkg) PetscCall(PetscLogEventExcludeClass(PETSC_RANDOM_CLASSID)); 53 } 54 /* Register package finalizer */ 55 PetscCall(PetscRegisterFinalize(PetscRandomFinalizePackage)); 56 PetscFunctionReturn(0); 57 } 58