Real CustomDT::computeDT() { Real new_dt; if(_t_step==3) new_dt=getCurrentDT()*_increase_rate; else new_dt=getCurrentDT(); return new_dt; }
Real RatioTimeStepper::computeDT() { if (_ratio > 1.0) if(_t_step % _step == 0) return std::min(getCurrentDT() * _ratio, _max_dt); else return getCurrentDT(); else return getCurrentDT(); }
Real TransientHalf::computeDT() { /** * We won't grow timesteps with this example so if the ratio > 1.0 we'll just * leave current_dt alone. */ if (_ratio < 1.0) // Shrink our timestep by the specified ratio or return the min if it's too small return std::max(getCurrentDT() * _ratio, _min_dt); else return getCurrentDT(); }
Real SolutionTimeAdaptiveDT::computeDT() { //Ratio grew so switch direction if (_sol_time_vs_dt > _old_sol_time_vs_dt && _sol_time_vs_dt > _older_sol_time_vs_dt) { _direction *= -1; // Make sure we take at least two steps in this new direction _old_sol_time_vs_dt = std::numeric_limits<Real>::max(); _older_sol_time_vs_dt = std::numeric_limits<Real>::max(); } // if (_t_step > 1) Real local_dt = _dt + _dt * _percent_change*_direction; if ((_adapt_log) && (libMesh::processor_id() == 0)) { Real out_dt = getCurrentDT(); if (out_dt > _dt_max) out_dt = _dt_max; _adaptive_log<<"***Time step: "<<_t_step<<", time = "<<_time+out_dt<<std::endl; _adaptive_log<<"Cur DT: "<<out_dt<<std::endl; _adaptive_log<<"Older Ratio: "<<_older_sol_time_vs_dt<<std::endl; _adaptive_log<<"Old Ratio: "<<_old_sol_time_vs_dt<<std::endl; _adaptive_log<<"New Ratio: "<<_sol_time_vs_dt<<std::endl; } return local_dt; }
Real DT2::computeDT() { Real curr_dt = getCurrentDT(); Real new_dt = curr_dt * std::pow(_e_tol / _error, 1.0 / _fe_problem.getNonlinearSystem().getTimeIntegrator()->order()); if (new_dt / curr_dt > _max_increase) new_dt = curr_dt * _max_increase; return new_dt; }
void DT2::step() { NonlinearSystem & nl = _fe_problem.getNonlinearSystem(); // returned reference is not used for anything? TransientNonlinearImplicitSystem & nl_sys = _fe_problem.getNonlinearSystem().sys(); TransientExplicitSystem & aux_sys = _fe_problem.getAuxiliarySystem().sys(); // solve the problem with full dt _fe_problem.solve(); _converged = nl.converged(); if (_converged) { // save the solution (for time step with dt) *_u1 = *nl_sys.current_local_solution; _u1->close(); *_aux1 = *aux_sys.current_local_solution; _aux1->close(); // take two steps with dt/2 _console << "Taking two dt/2 time steps" << std::endl; // restore solutions to the original state *nl_sys.current_local_solution = *_u_saved; *aux_sys.current_local_solution = *_aux_saved; nl_sys.current_local_solution->close(); aux_sys.current_local_solution->close(); _dt = getCurrentDT() / 2; // cut the time step in half _time = _time_old + _dt; // 1. step _fe_problem.onTimestepBegin(); // Compute Post-Aux User Objects (Timestep begin) _fe_problem.computeUserObjects(); _console << " - 1. step" << std::endl; Moose::setSolverDefaults(_fe_problem); nl.solve(); _converged = nl.converged(); if (_converged) { nl_sys.update(); _fe_problem.computeUserObjects(EXEC_TIMESTEP_END, UserObjectWarehouse::PRE_AUX); _fe_problem.advanceState(); _time += _dt; // 2. step _fe_problem.onTimestepBegin(); _fe_problem.computeUserObjects(); _console << " - 2. step" << std::endl; Moose::setSolverDefaults(_fe_problem); nl.solve(); _converged = nl.converged(); if (_converged) { nl_sys.update(); *_u2 = *nl_sys.current_local_solution; _u2->close(); // compute error *_u_diff = *_u2; *_u_diff -= *_u1; _u_diff->close(); _error = (_u_diff->l2_norm() / std::max(_u1->l2_norm(), _u2->l2_norm())) / getCurrentDT(); // restore _dt to its original value _dt = getCurrentDT(); } else { // solve failed, restore _time _time = _time_old; } } else { // solve failed, restore _time _time = _time_old; } if (!_converged) { *nl_sys.current_local_solution= *_u1; *nl_sys.old_local_solution = *_u1; *nl_sys.older_local_solution = *_u_saved; *aux_sys.current_local_solution = *_aux1; *aux_sys.old_local_solution = *_aux1; *aux_sys.older_local_solution = *_aux_saved; nl_sys.current_local_solution->close(); nl_sys.old_local_solution->close(); nl_sys.older_local_solution->close(); aux_sys.current_local_solution->close(); aux_sys.old_local_solution->close(); aux_sys.older_local_solution->close(); } } }