CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

resume a run with random generator

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By GerhardHolzinger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2016, 14:13
Default resume a run with random generator
  #1
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
Hi,

If I have a random number generator in a boundary condition (such as turbulentInlet BC), it needs a seed. Now assume for whatever reason this simulation stops and I want to resume it. If the seeding number has been passed then it only means the string of the random numbers will be reset to my very beginning time which means I'm getting duplicate data in the middle of my run.
Is there anyway to resume the random sequence? Like getting a seed number which if passed in would look like the same sequence is going on?
anishtain4 is offline   Reply With Quote

Old   August 3, 2016, 07:33
Default
  #2
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
You can avoid generating the same random sequences by using a seed value, that is different everytime you run your application.
The system time comes to mind. If you want to execute your application in parallel you can add the PID of the process to the time. Then the seed is different for each process.

Code:
// random stuff
#include "Random.H"
#include "clock.H"
Random ranGen( clock::getTime() + pid() ) ;

for ( int j = 0; j < 20; j ++)
{
    Info << ranGen.integer(1 , 100) << endl ;
}
szamani likes this.
GerhardHolzinger is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 18:45
[mesh manipulation] Cannot get refineMesh to run in parallel smschnob OpenFOAM Meshing & Mesh Conversion 2 June 3, 2014 11:20
How to run icoFsiFoam in parallel mode? AsDF OpenFOAM Running, Solving & CFD 2 February 21, 2014 07:56
Help-Edit Run in Progress BalanceChen CFX 0 March 30, 2011 09:23
resume and run fluent for another timestep via a c greg FLUENT 2 June 30, 2005 05:01


All times are GMT -4. The time now is 08:43.