bool IterationAdaptiveDT::constrainStep(Real & dt) { bool at_sync_point = TimeStepper::constrainStep(dt); // Limit the timestep to postprocessor value limitDTToPostprocessorValue(dt); // Limit the timestep to limit change in the function limitDTByFunction(dt); // Adjust to the next tfunc time if needed if (!_tfunc_times.empty() && _time + dt + _timestep_tolerance >= *_tfunc_times.begin()) { dt = *_tfunc_times.begin() - _time; if (_verbose) { _console << "Limiting dt to sync with dt function time: " << std::setw(9) << *_tfunc_times.begin() << " dt: " << std::setw(9) << dt << '\n'; } } return at_sync_point; }
Real AdaptiveTransient::computeConstrainedDT() { _diag.str(""); _diag.clear(); Real dt_cur = computeDT(); // Don't let the time step size exceed maximum time step size if (dt_cur > _dtmax) { dt_cur = _dtmax; _diag << "Limiting dt to dtmax: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << _dtmax << std::endl; } // Limit the timestep to limit change in the function //TODO: handle conflict of this with dtmin Real function_limited_dt = limitDTByFunction(dt_cur); if (function_limited_dt < dt_cur) { dt_cur = function_limited_dt; _diag << "Limiting dt to limit change in function. dt: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << dt_cur << std::endl; } // Don't allow time step size to be smaller than minimum time step size if (dt_cur < _dtmin) { dt_cur = _dtmin; _diag << "Increasing dt to dtmin: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << _dtmin << std::endl; } // Don't let time go beyond simulation end time if (_time_old + dt_cur > _end_time) { dt_cur = _end_time - _time_old; _diag << "Limiting dt for end time: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << _end_time << " dt: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << dt_cur << std::endl; } // Adjust to the next sync time if needed if (_remaining_sync_time && _time_old + dt_cur >= _curr_sync_time_iter->first) { dt_cur = _curr_sync_time_iter->first - _time_old; _synced_last_step = true; _last_sync_type = _curr_sync_time_iter->second; if (_last_sync_type == SYNC) _diag << "Limiting dt for sync time: "; else _diag << "Limiting dt to sync with dt function time: "; _diag << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << _curr_sync_time_iter->first << " dt: " << std::setw(9) << std::setprecision(6) << std::setfill('0') << std::showpoint << std::left << dt_cur << std::endl; if (++_curr_sync_time_iter == _sync_times.end()) _remaining_sync_time = false; _prev_dt = _dt; } if (_diag.str().size() > 0) { Moose::out << _diag.str() << std::endl; } return dt_cur; }