src/timestep.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  
// note: u is weighted by fm
  double timestep (const face vector u, double dtmax)
  {
    static double previous = 0.;
    dtmax /= CFL;
    foreach_face(reduction(min:dtmax))
      if (u.x[] != 0.) {
        double dt = Delta*cm[]/fabs(u.x[]);
        if (dt < dtmax) dtmax = dt;
      }
    dtmax *= CFL;
    if (dtmax > previous)
      dtmax = (previous + 0.1*dtmax)/1.1;
    previous = dtmax;
    return dtmax;
  }