CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   runtime.loop() and runtime.run() (https://www.cfd-online.com/Forums/openfoam-programming-development/123732-runtime-loop-runtime-run.html)

CoolKau September 19, 2013 13:01

runtime.loop() and runtime.run()
 
I am using sonicFoam in the versions 2.1.1 and 2.2.1 in a fairly simple setup.
In version 2.1.1 sonicFoam is using runtime.loop() for time iteration, while in 2.2.1 it has been changed to runtime.run().
I also manually changed version 2.1.1 to runtime.run() to be able to access the variable time step.

However, I realized that I get different results for runtime.run() and for runtime.loop() independent of the Open Foam version. So it seems to be a problem with the time iteration.

Does anyone else had similar problems?

luckycfd September 20, 2013 02:46

Hi CoolKau,

What's the meaning of this part of the code in the application solver?
Code:

while (runTime.loop())
{
...
}

Regards,
Hassan

CoolKau September 20, 2013 11:39

Quote:

Originally Posted by luckycfd (Post 452649)
Hi CoolKau,

What's the meaning of this part of the code in the application solver?
Code:

while (runTime.loop())
{
...
}

Regards,
Hassan


Hi Hassan,

I am not entirely sure what the difference of both of them are. It is my first time to dig deeper into the source code. They are basically running the solver repeatedly until the final time is reached. I know that one does allow for a variable time step (.run) and the other does not.

Also .\src\OpenFOAM\db\time.h has some annotations in it. But the only difference is that one iterates the time, while the other one just checks if the final time has been reached.

This is all I found out so far.

GPesch September 28, 2013 11:59

http://foam.sourceforge.net/docs/cpp...3d8c7fdc4638d9

This actually contains the same information as you already mentioned:

One is incrementing the time and is checking whether final time has been reached (loop), whilst the other one is only checking whether the final time has been reached (run), WITHOUT incrementing the timestep.

Please look into the 2 very short examples provided in my link to see how to use them: When using run, you need to increment the time manually as part of the iteration. If using loop, you do not need to do that.

So i guess the old version of sonicFoam didnt increment the time step during the iterated routine while the new version, which is using runtime.run() is calling a routine which is incrementing the time step somewhere in the process..

Georg.

CoolKau October 30, 2013 07:00

Quote:

Originally Posted by GPesch (Post 454062)
http://foam.sourceforge.net/docs/cpp...3d8c7fdc4638d9

This actually contains the same information as you already mentioned:

One is incrementing the time and is checking whether final time has been reached (loop), whilst the other one is only checking whether the final time has been reached (run), WITHOUT incrementing the timestep.

Please look into the 2 very short examples provided in my link to see how to use them: When using run, you need to increment the time manually as part of the iteration. If using loop, you do not need to do that.

So i guess the old version of sonicFoam didnt increment the time step during the iterated routine while the new version, which is using runtime.run() is calling a routine which is incrementing the time step somewhere in the process..

Georg.


Hi Georg,

thanks for your reply. Do you think you could check you sent the right link?

Also, so far I would think both functions work as they should. the time is iterated. However, I am still struggling to understand why both time function give different results. They both should just run the solver and stop it when the time limit is reached.

GPesch November 6, 2013 03:08

Actually I wanted to post this link :) No idea what went wrong:

http://foam.sourceforge.net/docs/cpp/a02307.html

Does sonicFoam 2.2.1 is giving you different results than sonicFoam 2.1.1 (in the original version without changing anything)?
Or do the differences only appear when you start changing from runTime.loop() to runTime.run() (or the other way round) in one of the two solvers?

CoolKau August 5, 2014 13:14

Hi Georg,
I am sorry for the late reply because I went on to different projects outside of the CFD world.

2.2.1 and the original 2.1.1 give different results. When switching 2.1.1 over to runtime.run() (same as 2.2.1) both versions agree. Therefore I thought the error is not in the version but in the time iteration.


All times are GMT -4. The time now is 00:13.