CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Time in OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 16, 2009, 22:37
Red face Time in OpenFOAM
  #1
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 8
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
In steady state simulations the time really isnt important. Basicaly your best solution is the most recent time stamp.

But when you get into time dependent simulations how do you get all of your time steps to be of equal accuracy?


Fluent would let you define the accptable amount of error per time step and would itterate that timestep until it was within range then moved on to the next one.

How does OpenFOAM go about this? Is it different for each solver?

Thanks!
ericnutsch is offline   Reply With Quote

Old   December 17, 2009, 01:00
Default
  #2
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,904
Rep Power: 27
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by ericnutsch View Post
In steady state simulations the time really isnt important. Basicaly your best solution is the most recent time stamp.

But when you get into time dependent simulations how do you get all of your time steps to be of equal accuracy?


Fluent would let you define the accptable amount of error per time step and would itterate that timestep until it was within range then moved on to the next one.

How does OpenFOAM go about this? Is it different for each solver?

Thanks!
In unsteady solvers based on the PISO algorithm you do not have such an approach. If you use an adaptive time step, the step size is controlled by the CFL condition. You assume implicitly that the time step is small enough to ensure convergence and accuracy.

In transient solvers using the PIMPLE/unsteady SIMPLE approach you can specify a number of sub-iterations per time step.

In all the cases, there is no explicit control on the residuals, which however can be easily added. Residuals can be retrieved easily defining a "solverPerformance" object
Code:
lduMatrix::solverPerformance sp;
then when you solve the equation just write
Code:
sp = solve ( /* Your equation here */);
and you will be able to retrieve the initial (you want the initial, not the final residual of the linear solver for your purpose) residual of each iteration with
Code:
sp.initialResidual()
Repeating this for all the equations you solve, and with some modification to the code you want to use, you can reproduce what is done in commercial codes

Best,
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats.
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   December 17, 2009, 13:48
Default
  #3
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 8
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Using the CFL condition to set the delta T seems like a good approach.

(U * deltaT)/deltaX < Courant <1

So for 10m/s and 1mm resolution, the time step must be less than 0.0001. Simple enough. So if i am going to solve a transient problem, do i have to initialize with a steady state solution? or do i just disregard the first 50 or so time steps?

Wikipedia also presents a two-dimensional equation. Does this equation need to be used for 2D problems or can I just use the magnitude (a^2 + b^2 = c^2) of the vectorial flow in the 1D equation?


I will try out your residual control code as I get further along in my project. Why do i want to view the initial residuals instead of the final ones?


Thanks for your post Alberto, it was most helpful!
ericnutsch is offline   Reply With Quote

Old   December 18, 2009, 08:12
Default
  #4
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,904
Rep Power: 27
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by ericnutsch View Post
Using the CFL condition to set the delta T seems like a good approach.

(U * deltaT)/deltaX < Courant <1

So for 10m/s and 1mm resolution, the time step must be less than 0.0001. Simple enough. So if i am going to solve a transient problem, do i have to initialize with a steady state solution? or do i just disregard the first 50 or so time steps?
An unsteady simulation is, after a sufficient time, independent from the initial condition, so you can use what you prefer. If your case admits a steady state, you should probably use a steady solver, if it doesn't, start from a physically sound initial condition, and start averaging when the flow is completely developed if you need averaged profiles.

Quote:
Wikipedia also presents a two-dimensional equation. Does this equation need to be used for 2D problems or can I just use the magnitude (a^2 + b^2 = c^2) of the vectorial flow in the 1D equation?
Just set the maximum Courant number you want to use, and turn the adaptive time step on

Quote:
I will try out your residual control code as I get further along in my project. Why do i want to view the initial residuals instead of the final ones?
Because you want the initial residual to become smaller in each time step, since if this happens, it means you are getting closer to your solution.
The "final" residual returned by solverPerformance is very small anyway, since it is the residual the linear solver returns after solving the linear system.

Quote:
Thanks for your post Alberto, it was most helpful!
You're welcome

Best,
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats.
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   December 18, 2009, 19:52
Default using adaptive time step?
  #5
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 8
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
How do i "turn the adaptive time step on "?


I read this forum: Adaptive timestepping

It said to include readTimeControls.H, CourantNo.H and setDeltaT.H, but it was a little brief. Turning it "on" sounds a lot more friendly. Could you please explain.


Thanks again for your help Alberto!
ericnutsch is offline   Reply With Quote

Old   December 18, 2009, 20:02
Default
  #6
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,904
Rep Power: 27
alberto will become famous soon enoughalberto will become famous soon enough
What solver are you using?

Best,
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats.
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   December 18, 2009, 23:52
Default
  #7
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 8
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Though i have not started this simulation yet, i currently plan to use pisoFoam.

I am planning on using a rotating reference frame so my solver may change in order to accommodated that aspect.

Lots of variables to consider when your getting started

Thanks again Alberto!
ericnutsch is offline   Reply With Quote

Old   December 19, 2009, 00:30
Default
  #8
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,904
Rep Power: 27
alberto will become famous soon enoughalberto will become famous soon enough
To "turn" the adaptive time step on in pisoFoam add

Code:
adjustTimeStep  yes;

maxCo           1;

maxDeltaT       1e-03;
in controlDict.

Of course the values of Co (Courant number) and the maximum time step are examples.

Best,
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats.
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.
alberto is offline   Reply With Quote

Old   December 19, 2009, 00:39
Default
  #9
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 8
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Thanks for all the excellent help Alberto!

I will give your code a try
ericnutsch is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time step size and max iterations per time step pUl| FLUENT 31 August 21, 2015 04:46
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
air bubble is disappear increasing time using vof xujjun CFX 9 June 9, 2009 07:59
DPM UDF particle position using the macro P_POS(p)[i] dm2747 FLUENT 0 April 17, 2009 01:29
The OpenFOAM extensions project mbeaudoin OpenFOAM 16 October 9, 2007 09:33


All times are GMT -4. The time now is 22:23.