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

Difference between runTime.run() and runTime.loop()

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 2 Post By hk318i
  • 1 Post By user_of_cfx

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 28, 2011, 05:57
Default Difference between runTime.run() and runTime.loop()
  #1
Member
 
Jim Knopf
Join Date: Dec 2010
Posts: 60
Rep Power: 15
JimKnopf is on a distinguished road
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
JimKnopf is offline   Reply With Quote

Old   October 28, 2011, 12:08
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
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
marupio is offline   Reply With Quote

Old   May 18, 2016, 06:12
Default
  #3
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
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();
So it looks like both do the same thing in different ways. My question is, is there a rule to choose which runTime option to use with what solver? Initially I thought this may be something to differentiate timesteps from the corrector iterations inside the PIMPLE algorithm for example, but then obviously both could do this equally well. Any insight to this will be appreciated.
user_of_cfx is offline   Reply With Quote

Old   May 19, 2016, 07:09
Default
  #4
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 18
hk318i is on a distinguished road
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
mostanad and reverseila like this.
hk318i is offline   Reply With Quote

Old   May 19, 2016, 07:18
Default
  #5
Member
 
Christa
Join Date: Apr 2011
Posts: 53
Rep Power: 15
user_of_cfx is on a distinguished road
Quote:
Originally Posted by hk318i View Post
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
I saw how it's used in rhoCentralFoam.. pretty cool. Cheers for the tip.
Ramzy1990 likes this.
user_of_cfx 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



All times are GMT -4. The time now is 03:56.