# Automatic timestep adjustment in a CFD solver

I have developed my own 3D Finite Volume Navier-Stokes solver based on projection method for nonuniform grid. I am looking to incorporate automatic timestep adjustment at each time step based on velocity. Is there any simple technique or procedure to calculate the size of timestep at each step for this problem?

• Do you mean a CFL condition? – EMP May 27 '19 at 6:01
• CFL condition and/or grid Fourier condition. How to specify the algorithm for new timestep based on them, especially for nonuniform grid? – engr.mechie May 27 '19 at 14:37
• Isn't your equation nonlinear? – nicoguaro May 27 '19 at 15:04
• Are you solving this to steady state or time accurate? How did you develop a 3D FV code without knowing how to implement a feasible timestep? Are you cell or vertex based? What type of elements are you using and what order are you? We need more information. – EMP May 27 '19 at 15:54
• I am solving it to steady state. So far, I had manually calculated the timestep for each case based on the CFL condition. My code is cell-based for a Cartesian grid. And yes, the equation is nonlinear. – engr.mechie May 28 '19 at 7:51

For flow solvers, the general rule is that the time step needs to satisfy some kind of "CFL condition", named after Courant, Friedrichs, and Lewy. This means that $$\Delta t \le C \min_{K} \frac{h_K}{\|\mathbf u\|_{L^\infty(K)}}$$ In other words, the time step must be proportional to the (minimum over all cells $$K$$) of the ratio of the mesh size $$h_K$$ and the velocity on that cell.

For explicit time stepping methods, this is a theoretical requirement: If you violate the condition (i.e., choose the time step too large) then the solution will become unstable. Each time stepping method leads to a particular value of the constant $$C$$.

For implicit time stepping methods, you can violate the condition without becoming unstable, but you will generally obtain a not-very-accurate solution if you choose the time step too large. That's because, if you think of it in a space-time diagram, a large time step with a small mesh size results in very elongated space-time cells. So people choose $$C=1$$ or $$C=2$$, or maybe even moderately larger values, but nothing crazy.

The condition above gives you a way to compute a time step adaptively.

• Thank you for your answer as it is closer to my requirement. But I have found a more comprehensive method. – engr.mechie May 29 '19 at 8:58

Yes! Normally what's done is called Method of Lines. Essentially, you discretize in space to get all of your operators, but instead of discretizing the time component, you leave that derivative along. Now you have a system of ODEs. Then you call an ODE solver like SUNDIALS or DifferentialEquations.jl which have tools for handling the sparsity of a PDE-derived ODE system (sparse factorization, preconditioned GMRES, IMEX integrators, etc.).

This describes the approach a bit and the second example in this tutorial shows how to build and optimize an ODE solver for a PDE semi-discretization.