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