Feng XING, > > I use Petsc random number generator. Every time I launch the code I get > same random number, the code is like this: > > PetscRandom rnd; > PetscRandomCreate(PETSC_COMM_WORLD,&rnd); > PetscRandomSetType(rnd,PETSCRAND); > > PetscScalar r; > PetscRandomGetValue(rnd,&r); > > I would like to ask two questions. How could I get different random number?
You can use PetscRandomSetSeed() and PetscRandomSeed(). See an example: petsc/src/dm/impls/plex/examples/tests/ex6.c > And what's the difference bewteen PETSCRAND and PETSCRAND48? > Two different random number generators, see http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscRandomType.html Hong
