|
[Sponsors] |
September 28, 2022, 23:33 |
|
#4 |
New Member
Chen Xiaoxiao
Join Date: Jun 2018
Location: China
Posts: 6
Rep Power: 7 |
If you use OpenFOAM's built-in random number class, you can use the functions prefixed with global to ensure that the random numbers generated each time are kept in sync on all MPI nodes,such as Random::globalSample01(), Random::globalGaussNormal().
see src/OpenFOAM/primitives/random/Random/Random.C for these source codes: Code:
Foam::scalar Foam::Random::globalSample01() { scalar value(-GREAT); if (Pstream::master()) { value = scalar01(); // generate random number on master MPI node. } Pstream::scatter(value); // broadcast this value to all MPI nodes. return value; } Code:
Random rndGen(<a fixed random seed>); scalar a = rndGen.sample01<scalar>(); Pout << "random number: "<< a << endl; scalar b = rndGen.globalSample01<scalar>(); Pout << "random number: "<< b << endl; // a is always equal to b here, and each MPI node have the same value of a and b. |
|
Tags |
correctboundaryconditions, cyclic boundary, surfacescalarfield |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 07:38 |
Radiation in semi-transparent media with surface-to-surface model? | mpeppels | CFX | 11 | August 22, 2019 07:30 |
Multiphase flow - incorrect velocity on inlet | Mike_Tom | CFX | 6 | September 29, 2016 01:27 |
Basic Nozzle-Expander Design | karmavatar | CFX | 20 | March 20, 2016 08:44 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 06:28 |