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