|
[Sponsors] |
Difference between runTime.run() and runTime.loop() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 28, 2011, 05:57 |
Difference between runTime.run() and runTime.loop()
|
#1 |
Member
Jim Knopf
Join Date: Dec 2010
Posts: 60
Rep Power: 15 |
Hi there!
Though I don't have a problem, recently I was wondering why there are two strategies to iterate in time. First there is runTime.loop() which is used as a condition for a while loop. Second there is runTime.run() as a condition for the while loop and runTime++ for iterating Does this make sense? I don't get. Maybe someone can enlighten me. greetz Jim |
|
October 28, 2011, 12:08 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
Read src/OpenFOAM/db/Time/time.H, it has comments describing the difference. I think .loop increments runTime, whereas .run is only a test if the run should continue, but there may be some fine differences with function objects.
__________________
~~~ Follow me on twitter @DavidGaden |
|
May 18, 2016, 06:12 |
|
#3 |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
I am bringing this forward again and about to ask again... From Time.H (bold highlighting by me):
Code:
//- Return true if run should continue, // also invokes the functionObjectList::end() method // when the time goes out of range // \note // For correct behaviour, the following style of time-loop // is recommended: // \code // while (runTime.run()) // { // runTime++; // solve; // runTime.write(); // } // \endcode virtual bool run() const; //- Return true if run should continue and if so increment time // also invokes the functionObjectList::end() method // when the time goes out of range // \note // For correct behaviour, the following style of time-loop // is recommended: // \code // while (runTime.loop()) // { // solve; // runTime.write(); // } // \endcode virtual bool loop(); |
|
May 19, 2016, 07:09 |
|
#4 |
Senior Member
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18 |
Simply, run() gives the developer a chance to calculate whatever needed before updating the time index. On the other hand loop(), updates the time at the beginning of the loop.
You are absolutely right, based on these examples in this comment both are exactly the same but it is not always the case. I can recall one example, check rhoCentralFoam, you will find that run() is used because interpolation is required before solving the equations. Best Regards, Hassan Kassem |
|
May 19, 2016, 07:18 |
|
#5 | |
Member
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15 |
Quote:
|
||
|
|