src/timestep.h

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    // 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/fabs(u.x[]);
    #if EMBED
          assert (fm.x[]);
          dt *= fm.x[];
    #else
          dt *= cm[];
    #endif
          if (dt < dtmax) dtmax = dt;
        }
      dtmax *= CFL;
      if (dtmax > previous)
        dtmax = (previous + 0.1*dtmax)/1.1;
      previous = dtmax;
      return dtmax;
    }