/* PetscRandomSetTypeFromOptions_Private - Sets the type of random generator from user options. Defaults to type PETSCRAND48 or PETSCRAND. Collective on PetscRandom Input Parameter: . rnd - The random number generator context Level: intermediate .keywords: PetscRandom, set, options, database, type .seealso: PetscRandomSetFromOptions(), PetscRandomSetType() */ static PetscErrorCode PetscRandomSetTypeFromOptions_Private(PetscRandom rnd) { PetscBool opt; const char *defaultType; char typeName[256]; PetscErrorCode ierr; PetscFunctionBegin; if (((PetscObject)rnd)->type_name) { defaultType = ((PetscObject)rnd)->type_name; } else { #if defined(PETSC_HAVE_DRAND48) defaultType = PETSCRAND48; #elif defined(PETSC_HAVE_RAND) defaultType = PETSCRAND; #endif } if (!PetscRandomRegisterAllCalled) {ierr = PetscRandomRegisterAll();CHKERRQ(ierr);} ierr = PetscOptionsFList("-random_type","PetscRandom type","PetscRandomSetType",PetscRandomList,defaultType,typeName,256,&opt);CHKERRQ(ierr); if (opt) { ierr = PetscRandomSetType(rnd, typeName);CHKERRQ(ierr); } else { ierr = PetscRandomSetType(rnd, defaultType);CHKERRQ(ierr); } PetscFunctionReturn(0); }
/* PetscRandomSetTypeFromOptions_Private - Sets the type of random generator from user options. Defaults to type PETSCRAND48 or PETSCRAND. Collective on PetscRandom Input Parameter: . rnd - The random number generator context Level: intermediate .keywords: PetscRandom, set, options, database, type .seealso: PetscRandomSetFromOptions(), PetscRandomSetType() */ static PetscErrorCode PetscRandomSetTypeFromOptions_Private(PetscOptions *PetscOptionsObject,PetscRandom rnd) { PetscBool opt; const char *defaultType; char typeName[256]; PetscErrorCode ierr; PetscFunctionBegin; if (((PetscObject)rnd)->type_name) { defaultType = ((PetscObject)rnd)->type_name; } else { defaultType = PETSCRANDER48; } ierr = PetscRandomRegisterAll(); CHKERRQ(ierr); ierr = PetscOptionsFList("-random_type","PetscRandom type","PetscRandomSetType",PetscRandomList,defaultType,typeName,256,&opt); CHKERRQ(ierr); if (opt) { ierr = PetscRandomSetType(rnd, typeName); CHKERRQ(ierr); } else { ierr = PetscRandomSetType(rnd, defaultType); CHKERRQ(ierr); } PetscFunctionReturn(0); }
/*@C PetscRandomInitializePackage - This function initializes everything in the PetscRandom package. It is called from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to PetscRandomCreate() when using static libraries. Level: developer .keywords: PetscRandom, initialize, package .seealso: PetscInitialize() @*/ PetscErrorCode PetscRandomInitializePackage(void) { PetscErrorCode ierr; PetscFunctionBegin; if (PetscRandomPackageInitialized) PetscFunctionReturn(0); PetscRandomPackageInitialized = PETSC_TRUE; /* Register Class */ ierr = PetscClassIdRegister("PetscRandom",&PETSC_RANDOM_CLASSID);CHKERRQ(ierr); ierr = PetscRandomRegisterAll();CHKERRQ(ierr); ierr = PetscRegisterFinalize(PetscRandomFinalizePackage);CHKERRQ(ierr); PetscFunctionReturn(0); }