Globally instantiated "Random"
Hi All,
I have a solver that I have I built that uses random numbers in a number of places. In the existing code, if a new "Random()" object is instantiated in more than one place, the random numbers are re-seeded (usually with the same seed) every time a new object is created. In 1.5.x I changed Random() to initialise it self, and only reseed if explicitly asked. As follows: (in Random.H) Code:
//- Construct given seed Code:
// construct given seed Code:
+ if (!initialised) { But before I do, i need to know if what I am doing is a good idea? will this have any unforseen side effects? (so far I haven't come across any). Is it worth including upstream? It should be entirely compatible with existing code, but allows you to grab a random number anywhere by using Code:
Random random(); Am i missing something? Cheers, Andrew |
Hey Andrew,
your suggestion is exactly what I am looking for... Could you please offer the whole part from Random.C since I get an error Code:
my_test.C:52:28: error: request for member ‘scalar01’ in ‘random’, which is of non-class type ‘Foam::Random()’ Thanks Best wishes Sebastian |
All times are GMT -4. The time now is 07:41. |