Exemplo n.º 1
0
Real
IterationAdaptiveDT::computeDT()
{
  Real dt = _dt_old;

  if (_cutback_occurred)
  {
    _cutback_occurred = false;
    if (_adaptive_timestepping)
    {
      // Don't allow it to grow this step, but shrink if needed
      bool allowToGrow = false;
      computeAdaptiveDT(dt, allowToGrow);
    }
  }
  else if (_tfunc_last_step)
  {
    _tfunc_last_step = false;
    _sync_last_step = false;
    dt = _time_ipol.sample(_time_old);

    if (_verbose)
    {
      _console << "Setting dt to value specified by dt function: "
               << std::setw(9) << dt
               << '\n';
    }
  }
  else if (_sync_last_step)
  {
    _sync_last_step = false;
    dt = _dt_old;

    if (_verbose)
    {
      _console << "Setting dt to value used before sync: "
               << std::setw(9) << dt
               << '\n';
    }
  }
  else if (_adaptive_timestepping)
    computeAdaptiveDT(dt);
  else if (_use_time_ipol)
    dt = computeInterpolationDT();
  else
  {
    dt *= _growth_factor;
    if (dt > _dt_old * _growth_factor)
      dt = _dt_old * _growth_factor;
  }

  return dt;
}
Exemplo n.º 2
0
Real
AdaptiveTransient::computeDT()
{
  Real dt = _dt;

  if (!lastSolveConverged())
  {
    if (dt <= _dtmin)
    { //Can't cut back any more
      mooseError("Solve failed and timestep already at dtmin, cannot continue!");
    }

    dt = _cutback_factor * _dt;
    if (dt < _dtmin)
    {
      dt =  _dtmin;
    }

    if (_caught_exception)
    {
      _diag << "Encountered exception with dt: ";
      _caught_exception = false;
    }
    else
      _diag << "Solve failed with dt: ";

    _diag << std::setw(9)
          << std::setprecision(6)
          << std::setfill('0')
          << std::showpoint
          << std::left
          << _dt
          << "  Retrying with reduced dt: "
          << std::setw(9)
          << std::setprecision(6)
          << std::setfill('0')
          << std::showpoint
          << std::left
          << dt
          << std::endl;
  }

  else if ( _t_step == 1 ) //First time step, don't change the timestep ...
  {
  }

  else if ( _t_step <= _n_startup_steps ) //Don't change the timestep ...
  {
    if (_synced_last_step) //  ... unless we did a sync during the startup steps
    {
      dt = _prev_dt;

      if (_last_sync_type == SYNC)
        _diag << "Within n_startup_steps, resetting dt to value used before sync: ";
      else
        _diag << "Within n_startup_steps, resetting dt to value used before syncing with dt function: ";

      _diag << std::setw(9)
            << std::setprecision(6)
            << std::setfill('0')
            << std::showpoint
            << std::left
            << dt
            << std::endl;
    }
    else
    {
      _diag << "Within n_startup_steps, maintaining dt : "
            << std::setw(9)
            << std::setprecision(6)
            << std::setfill('0')
            << std::showpoint
            << std::left
            << dt
            << std::endl;
    }
  }

  else if ( _cutback_occurred ) //Don't allow it to grow this step, but shrink if needed
  {
    if (_adaptive_timestepping)
    {
      bool allowToGrow(false);
      computeAdaptiveDT(dt,allowToGrow);
    }
  }

  else if (_synced_last_step)
  {
    if (_last_sync_type == SYNC)
    {
      dt = _prev_dt;
      _diag << "Resetting dt to value used before sync: ";
    }
    else if (_last_sync_type == TIME_FUNC)
    {
      if (!_use_time_ipol)
        mooseError("Can't have TIME_FUNC sync type without time_ipol");
      dt = _time_ipol.sample(_time_old);
      _diag << "Setting dt to value specified by dt function: ";
    }

    _diag << std::setw(9)
          << std::setprecision(6)
          << std::setfill('0')
          << std::showpoint
          << std::left
          << dt
          << std::endl;
  }

  else
  {
    if (_adaptive_timestepping)
    {
      computeAdaptiveDT(dt);
    }
    else
    {
      if (_use_time_ipol)
      {
        dt = _time_ipol.sample(_time_old);
        if (dt > _dt * _growth_factor)
        {
          dt = _dt * _growth_factor;

          _diag << "Growing dt to recover from cutback.  old dt: "
                << std::setw(9)
                << std::setprecision(6)
                << std::setfill('0')
                << std::showpoint
                << std::left
                << _dt
                << " new dt: "
                << std::setw(9)
                << std::setprecision(6)
                << std::setfill('0')
                << std::showpoint
                << std::left
                << dt
                << std::endl;
        }
      }
      else
      {
        dt = _input_dt;
        if (dt > _dt * _growth_factor)
        {
          dt = _dt * _growth_factor;

          _diag << "Growing dt to recover from cutback.  old dt: "
                << std::setw(9)
                << std::setprecision(6)
                << std::setfill('0')
                << std::showpoint
                << std::left
                << _dt
                << " new dt: "
                << std::setw(9)
                << std::setprecision(6)
                << std::setfill('0')
                << std::showpoint
                << std::left
                << dt
                << std::endl;
        }
      }
    }
  }

  if (!lastSolveConverged())
    _cutback_occurred = true;
  else
    _cutback_occurred = false;

  _synced_last_step = false;

  return dt;
}