Random number generation
Hi all,
I want to generate random numbers in OF 2.2.0 between -1 and +1 for the whole mesh initially which will remain same for all time steps. Can you advice how to do this ? with regards, |
Simple task,
there is a class called Random. An example is in my Gray-Scott-Solver ... https://bitbucket.org/shor-ty/graysc...e-view-default |
Quote:
|
Hi,
sure, you just define a variable that changes and then you give it as an argument to the class. |
Hi, is it possible to generate random list of "N" numbers between given range (a,b)? using that class? Like i need some 10 numbers between say 0 to 100.
And it gives following error when i run that script. Quote:
|
Example to generate a random number between 0 and 1
#include <iostream>
#include "fvCFD.H" #include "Random.H" #include "Time.H" int main () { Random randObj(clock::getTime()); Info << randObj.scalar01()<< endl; } |
Quote:
i am getting following error when i use your code. Code:
testCode.C: In function ‘int main(int, char**)’: |
Quote:
Code:
Random rng; Code:
Random::uniformGeneratorOp<scalar> randVal(0,10); |
All times are GMT -4. The time now is 07:06. |