# Time in OpenFOAM

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

 December 16, 2009, 22:37 Time in OpenFOAM #1 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 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!

December 17, 2009, 01:00
#2
Senior Member

Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,911
Rep Power: 28
Quote:
 Originally Posted by 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!
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 (current status: http://albertopassalacqua.com/?p=1541)
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.

 December 17, 2009, 13:48 #3 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 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!

December 18, 2009, 08:12
#4
Senior Member

Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,911
Rep Power: 28
Quote:
 Originally Posted by 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?
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:
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 (current status: http://albertopassalacqua.com/?p=1541)
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.

 December 18, 2009, 19:52 using adaptive time step? #5 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 How do i "turn the adaptive time step on "? I read this forum: http://www.cfd-online.com/Forums/ope...estepping.html 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!

 December 18, 2009, 20:02 #6 Senior Member   Alberto Passalacqua Join Date: Mar 2009 Location: Ames, Iowa, United States Posts: 1,911 Rep Power: 28 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 (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using.

 December 18, 2009, 23:52 #7 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 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!

 December 19, 2009, 00:30 #8 Senior Member   Alberto Passalacqua Join Date: Mar 2009 Location: Ames, Iowa, United States Posts: 1,911 Rep Power: 28 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 (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using.

 December 19, 2009, 00:39 #9 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 Thanks for all the excellent help Alberto! I will give your code a try

August 24, 2016, 08:19
#10
New Member

larmes
Join Date: Aug 2016
Posts: 26
Rep Power: 3
Quote:
 Originally Posted by ericnutsch In steady state simulations the time really isnt important. Basicaly your best solution is the most recent time stamp.
why is the most recent the best solution in steady states?

 August 25, 2016, 03:16 #11 Senior Member   Eric Nutsch Join Date: Sep 2009 Location: Eugene, Oregon USA Posts: 113 Rep Power: 10 By definition, a steady state solution does not consider time. If said conditions exist for infinite time I will arrive at an unchanging "steady state". A better phrasing would be: "your solution is the most recent iteration as it has undergone the most iterations and will be most accurate." Many solvers use a timestep variable to track iterations to get to steady state.

 June 21, 2017, 22:29 Bug in openfoam simulation #12 New Member   Golden Join Date: Jun 2017 Posts: 4 Rep Power: 2 Hello everyone, I am doing a simple jet combustion with the following boundary. The mesh was converted to FOAM. The simulation runs. But it is showing, Pimple iteration 1: and it is not converged. The system directory was same to basic tutorial. Do i need to change fvscheme directory and solution directory or anything? /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.4.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class polyBoundaryMesh; location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 4 ( outlet { type patch; nFaces 6416; startFace 7736555; } sides { type wall; inGroups 1(wall); nFaces 64638; startFace 7742971; } base { type patch; inGroups 1(patch); nFaces 6292; startFace 7807609; } inlet { type patch; nFaces 6; startFace 7813901; } ) // ************************************************** *********************** //

September 25, 2017, 18:02
#13
New Member

Patrick
Join Date: Apr 2016
Posts: 6
Rep Power: 3
Quote:
 Originally Posted by ericnutsch By definition, a steady state solution does not consider time. If said conditions exist for infinite time I will arrive at an unchanging "steady state". A better phrasing would be: "your solution is the most recent iteration as it has undergone the most iterations and will be most accurate." Many solvers use a timestep variable to track iterations to get to steady state.
Hi Eric,

I just stumbled onto this thread you posted last year. I am relatively new with OpenFoam. I use steady state solver for channel flow simulation. Normally I will expect the computation to complete after convergence (depending on the residual control value, usually in the order of 10^-5) or when i dont notice reasonable changes in flow distribution from one time step to the next.

But from your statement, am i right to deduce that convergence is not necessary? In which case, what could be a reasonable iteration time for steady state computation if one is not aiming for convergence?

Thanks for time
Patrick

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post pUl| FLUENT 31 August 21, 2015 04:46 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36 xujjun CFX 9 June 9, 2009 07:59 dm2747 FLUENT 0 April 17, 2009 01:29 mbeaudoin OpenFOAM 16 October 9, 2007 09:33

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