- **OpenFOAM Running, Solving & CFD**
(*https://www.cfd-online.com/Forums/openfoam-solving/*)

- - **Adaptive timestepping**
(*https://www.cfd-online.com/Forums/openfoam-solving/57961-adaptive-timestepping.html*)

Hi,
I'm thinking of using tHi,
I'm thinking of using the standard features for adaptive timestepping (found in finiteVolume library, an used in some standard solvers) in one of my own solvers. These standard features are based on keeping a certain max Courant number. Is the Courant number the only sensible criterion? If my transient solution is approching a steady state, the Courant number does not necessarily decrease (?), but with an implicit time scheme it should still be possible to increase the timestep dramatically, without much loss of accuracy. Or? Thanks in advance for any comments, Ola |

Hi Ola,
Time step criterionHi Ola,
Time step criterion is a key aspect, despite the fact that not always is deeply considered. If you are using an implicit time scheme you would not have stability problems, however, if you are interested in an accurate transient simulation, time step is crucial (your time step should allow you to observe main details of fluid evolution). The criterion depends on the equation you are solving, that is, on the characteristic flow evolution (inertia, diffusion, Lorentz, etc.). The Courant number (CFL) is obtained from stability analysis considering only inertial effects. In general this criterion is enough. If you are using RANS models, your effective viscosity might be considerable, thus, the diffusive criterion should also be considered. If you have any other phenomenon included in your fluid, as for example, electromagnetics, it might also be necessary to consider it. You might also take care on considering which is the maximum Courant number (or other criterion) you take. It depends on the numerical schemes you work with. To obtain a more detailed overview about it, I would suggest you to reed 'Joe D. Hoffman. Numerical Methods for Engineers and Scientists'. Finally, when you are arriving at the steady state, you will see that, for a fixed Courant number the time step obtained is constant (due to no changes in fluid variables along the time). Hope it helps! Regards, elisabet |

Hi Elisabet,
Thanks for youHi Elisabet,
Thanks for your reply. You have a really good point in considering WHICH courant number to focus on, when there's many physical mechanisms in play. I'll look for Hoffman's book, too. I have now implemented the OF features for adjustable time-stepping (used in some of the standard OF solvers), which adjusts the timestep to keep constant Courant number. Based on your suggestion, I computed a Courant number for the "fastest" of the physical mechanisms in my problem (transport of free electrons in this case). The time-step adjustment works really well. I also implemented an inner iteration loop within the time step loop (see separate post), so I can make sure the non-linear coupling between the equations is properly converged in each time step. In that loop, I apply the OF under-relaxation features for one of the source terms. It works wonders... I've varied my Courant number between 0.2 and 2. I see that it does not necessarily pay to have large Co and advance faster in time, because it just means I need to do more non-linear iterations in each time-step to stabilize the non-linear coupling... Best regards, Ola |

Hi Ola,
Does your simulatioHi Ola,
Does your simulation reach the steady state at the same time when using different Courant numbers? elisabet |

Hello,
I am not able to figHello,
I am not able to figure out, how to use adaptive time stepping in my solver. I extended turbFoam solver from OF-1.5, with two scalar transport(say red water and blue water) to see the mixing of two inlet flows in a T-section. Currently I using a time-step of 0.001 and getting max Co number of the order of ~0.001. If I increase the time-step to 0.01 or 0.005 the Co number increases drastically and solver aborts (in 3-4 time steps). Hence I was considering the use of adaptive time stepping scheme. However I could not find anything explaining this in UserGuide or ProgGuide or wiki. The closest I came with google is this thread... There is one file in ../OpenFoam-1.5/src/finiteVolume/cfdtools/incompressible/CourantNo.H I could not figure out much from that... Please shed some light on adaptive time stepping. Thanks Rishi |

Hi Rishi,
The procedure is Hi Rishi,
The procedure is always the same. You need 3 include files: readTimeControls.H, CourantNo.H and setDeltaT.H. The latest two include files must be located inside your time loop in order to first evaluate the actual Courant and, from this result, define the new time step. The include setInitialDeltaT.H is optional. See for example icoDyMFoam (in .dep file you will find the location of the included files and read what they do) Good luck! elisabet |

Hi,
I also want to use an adaptive timestepping. I've read the discussion above and I've tried to do this but it doesn't work. I am not sure where you have to change this. I've included the 3 files in OpenFoam-1.6x/applications/solvers/incompressible/simpleFoam/simpleFoam.C because I'm using the simpleFoam solver. After this i've included 2 files (CourantNo.H and setDeltaT.H) in the time loop. Is this correct or do i have to include the files somewhere else? Regards, Jochem |

Hi,
I found out that you still have to do a command to "load" the "new" solver using the "wmake" command. When i do this i get the following error : cpp: Internal error: Floating point exception (program cc1) Please submit a full bug report. See <http://gcc.gnu.org/bugs.html> for instructions. make: *** [linux64GccDPOpt/options] Error 1 cpp: Internal error: Floating point exception (program cc1) Please submit a full bug report. See <http://gcc.gnu.org/bugs.html> for instructions. make: *** [linux64GccDPOpt/files] Error 1 wmake error: file 'Make/linux64GccDPOpt/objectFiles' could not be created For clarity I also post the simpleFoam.C file. It looks like this : #include "fvCFD.H" #include "singlePhaseTransportModel.H" #include "RASModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readSIMPLEControls.H" #include "initConvergenceCheck.H" #include "CourantNo.H" #include "setDeltaT.H" runTime++; p.storePrevIter(); // Pressure-velocity SIMPLE corrector { #include "UEqn.H" #include "pEqn.H" } turbulence->correct(); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; #include "convergenceCheck.H" } Info<< "End\n" << endl; return 0; } Can someone tell my what i am doing wrong? Regards, Jochem |

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