Ejemplo n.º 1
0
Transient::Transient(const InputParameters & parameters) :
    Executioner(parameters),
    _problem(_fe_problem),
    _time_scheme(getParam<MooseEnum>("scheme")),
    _t_step(_problem.timeStep()),
    _time(_problem.time()),
    _time_old(_problem.timeOld()),
    _dt(_problem.dt()),
    _dt_old(_problem.dtOld()),
    _unconstrained_dt(declareRecoverableData<Real>("unconstrained_dt", -1)),
    _at_sync_point(declareRecoverableData<bool>("at_sync_point", false)),
    _first(declareRecoverableData<bool>("first", true)),
    _multiapps_converged(declareRecoverableData<bool>("multiapps_converged", true)),
    _last_solve_converged(declareRecoverableData<bool>("last_solve_converged", true)),
    _end_time(getParam<Real>("end_time")),
    _dtmin(getParam<Real>("dtmin")),
    _dtmax(getParam<Real>("dtmax")),
    _num_steps(getParam<unsigned int>("num_steps")),
    _n_startup_steps(getParam<int>("n_startup_steps")),
    _steps_taken(0),
    _trans_ss_check(getParam<bool>("trans_ss_check")),
    _ss_check_tol(getParam<Real>("ss_check_tol")),
    _ss_tmin(getParam<Real>("ss_tmin")),
    _old_time_solution_norm(declareRecoverableData<Real>("old_time_solution_norm", 0.0)),
    _sync_times(_app.getOutputWarehouse().getSyncTimes()),
    _abort(getParam<bool>("abort_on_solve_fail")),
    _time_interval(declareRecoverableData<bool>("time_interval", false)),
    _start_time(getParam<Real>("start_time")),
    _timestep_tolerance(getParam<Real>("timestep_tolerance")),
    _target_time(declareRecoverableData<Real>("target_time", -1)),
    _use_multiapp_dt(getParam<bool>("use_multiapp_dt")),
    _picard_it(declareRecoverableData<int>("picard_it", 0)),
    _picard_max_its(getParam<unsigned int>("picard_max_its")),
    _picard_converged(declareRecoverableData<bool>("picard_converged", false)),
    _picard_initial_norm(declareRecoverableData<Real>("picard_initial_norm", 0.0)),
    _picard_timestep_begin_norm(declareRecoverableData<Real>("picard_timestep_begin_norm", 0.0)),
    _picard_timestep_end_norm(declareRecoverableData<Real>("picard_timestep_end_norm", 0.0)),
    _picard_rel_tol(getParam<Real>("picard_rel_tol")),
    _picard_abs_tol(getParam<Real>("picard_abs_tol")),
    _verbose(getParam<bool>("verbose"))
{
  _problem.getNonlinearSystem().setDecomposition(_splitting);
  _t_step = 0;
  _dt = 0;
  _next_interval_output_time = 0.0;

  // Either a start_time has been forced on us, or we want to tell the App about what our start time is (in case anyone else is interested.
  if (_app.hasStartTime())
    _start_time = _app.getStartTime();
  else if (parameters.paramSetByUser("start_time"))
    _app.setStartTime(_start_time);

  _time = _time_old = _start_time;
  _problem.transient(true);

  if (!_restart_file_base.empty())
    _problem.setRestartFile(_restart_file_base);

  setupTimeIntegrator();

  if (_app.halfTransient()) // Cut timesteps and end_time in half...
  {
    _end_time /= 2.0;
    _num_steps /= 2.0;

    if (_num_steps == 0) // Always do one step in the first half
      _num_steps = 1;
  }
}
Ejemplo n.º 2
0
Transient::Transient(const std::string & name, InputParameters parameters) :
    Executioner(name, parameters),
    _problem(*parameters.getCheckedPointerParam<FEProblem *>("_fe_problem", "This might happen if you don't have a mesh")),
    _time_scheme(getParam<MooseEnum>("scheme")),
    _t_step(_problem.timeStep()),
    _time(_problem.time()),
    _time_old(_problem.timeOld()),
    _dt(_problem.dt()),
    _dt_old(_problem.dtOld()),
    _unconstrained_dt(declareRestartableData<Real>("unconstrained_dt", -1)),
    _at_sync_point(declareRestartableData<bool>("at_sync_point", false)),
    _first(declareRecoverableData<bool>("first", true)),
    _last_solve_converged(declareRestartableData<bool>("last_solve_converged", true)),
    _end_time(getParam<Real>("end_time")),
    _dtmin(getParam<Real>("dtmin")),
    _dtmax(getParam<Real>("dtmax")),
    _num_steps(getParam<unsigned int>("num_steps")),
    _n_startup_steps(getParam<int>("n_startup_steps")),
    _steps_taken(0),
    _trans_ss_check(getParam<bool>("trans_ss_check")),
    _ss_check_tol(getParam<Real>("ss_check_tol")),
    _ss_tmin(getParam<Real>("ss_tmin")),
    _old_time_solution_norm(declareRestartableData<Real>("old_time_solution_norm", 0.0)),
    _sync_times(_app.getOutputWarehouse().getSyncTimes()),
    _abort(getParam<bool>("abort_on_solve_fail")),
    _time_interval(declareRestartableData<bool>("time_interval", false)),
    _start_time(getParam<Real>("start_time")),
    _timestep_tolerance(getParam<Real>("timestep_tolerance")),
    _target_time(declareRestartableData<Real>("target_time", -1)),
    _use_multiapp_dt(getParam<bool>("use_multiapp_dt")),
    _picard_it(0),
    _picard_max_its(getParam<unsigned int>("picard_max_its")),
    _picard_converged(false),
    _picard_initial_norm(0.0),
    _picard_rel_tol(getParam<Real>("picard_rel_tol")),
    _picard_abs_tol(getParam<Real>("picard_abs_tol")),
    _verbose(getParam<bool>("verbose"))
{
  _problem.getNonlinearSystem().setDecomposition(_splitting);
  _t_step = 0;
  _dt = 0;
  _next_interval_output_time = 0.0;

  // Either a start_time has been forced on us, or we want to tell the App about what our start time is (in case anyone else is interested.
  if (_app.hasStartTime())
    _start_time = _app.getStartTime();
  else
    _app.setStartTime(_start_time);

  _time = _time_old = _start_time;
  _problem.transient(true);

  if (parameters.isParamValid("predictor_scale"))
  {
    mooseWarning("Parameter 'predictor_scale' is deprecated, migrate your input file to use Predictor sub-block.");

    Real predscale = getParam<Real>("predictor_scale");
    if (predscale >= 0.0 && predscale <= 1.0)
    {
      InputParameters params = _app.getFactory().getValidParams("SimplePredictor");
      params.set<Real>("scale") = predscale;
      _problem.addPredictor("SimplePredictor", "predictor", params);
    }

    else
      mooseError("Input value for predictor_scale = "<< predscale << ", outside of permissible range (0 to 1)");

  }

  if (!_restart_file_base.empty())
    _problem.setRestartFile(_restart_file_base);

  setupTimeIntegrator();

  if (_app.halfTransient()) // Cut timesteps and end_time in half...
  {
    _end_time /= 2.0;
    _num_steps /= 2.0;

    if (_num_steps == 0) // Always do one step in the first half
      _num_steps = 1;
  }
}
Ejemplo n.º 3
0
AdaptiveTransient::AdaptiveTransient(const std::string & name, InputParameters parameters) :
    Executioner(name, parameters),
    _problem(*getParam<FEProblem *>("_fe_problem")),
    _time_scheme(getParam<MooseEnum>("scheme")),
    _t_step(_problem.timeStep()),
    _time(_problem.time()),
    _time_old(_time),
    _input_dt(getParam<Real>("dt")),
    _dt(_problem.dt()),
    _dt_old(_problem.dtOld()),
    _prev_dt(-1),
    _synced_last_step(false),
    _end_time(getParam<Real>("end_time")),
    _dtmin(getParam<Real>("dtmin")),
    _dtmax(getParam<Real>("dtmax")),
    _num_steps(getParam<Real>("num_steps")),
    _n_startup_steps(getParam<int>("n_startup_steps")),
    _linear_iteration_ratio(isParamValid("linear_iteration_ratio") ? getParam<int>("linear_iteration_ratio") : 25),  // Default to 25
    _adaptive_timestepping(false),
    _timestep_limiting_function(NULL),
    _max_function_change(-1.0),
    _trans_ss_check(getParam<bool>("trans_ss_check")),
    _ss_check_tol(getParam<Real>("ss_check_tol")),
    _ss_tmin(getParam<Real>("ss_tmin")),
    _converged(true),
    _caught_exception(false),
    _remaining_sync_time(true),
    _time_ipol(getParam<std::vector<Real> >("time_t"),
               getParam<std::vector<Real> >("time_dt")),
    _use_time_ipol(_time_ipol.getSampleSize() > 0),
    _growth_factor(getParam<Real>("growth_factor")),
    _cutback_factor(getParam<Real>("cutback_factor")),
    _cutback_occurred(false)
{
  mooseWarning("AdaptiveTransient is deprecated and will be removed in the near future.  Please replace with Transient and IterationAdaptiveDT");
  _t_step = 0;
  _dt = 0;
  _time = _time_old = getParam<Real>("start_time");
  _problem.transient(true);

  if (parameters.isParamValid("predictor_scale"))
  {
    Real predscale = getParam<Real>("predictor_scale");
    if (predscale >= 0.0 and predscale <= 1.0)
    {
      InputParameters params = _app.getFactory().getValidParams("Predictor");
      params.set<Real>("scale") = predscale;
      _problem.addPredictor("Predictor", "predictor", params);
    }
    else
    {
      mooseError("Input value for predictor_scale = "<< predscale << ", outside of permissible range (0 to 1)");
    }
  }

  if (isParamValid("optimal_iterations"))
  {
    _adaptive_timestepping=true;
    _optimal_iterations = getParam<int>("optimal_iterations");
    if (isParamValid("iteration_window"))
    {
      _iteration_window = getParam<int>("iteration_window");
    }
    else
    {
      _iteration_window = ceil(_optimal_iterations/5.0);
    }
  }
  else
  {
    if (isParamValid("iteration_window"))
    {
      mooseError("'optimal_iterations' must be used for 'iteration_window' to be used");
    }
    if (isParamValid("linear_iteration_ratio"))
    {
      mooseError("'optimal_iterations' must be used for 'linear_iteration_ratio' to be used");
    }
  }

  if (isParamValid("timestep_limiting_function"))
  {
    _timestep_limiting_function_name = getParam<std::string>("timestep_limiting_function");
    //TODO:  It would be nice to grab the function here, but it doesn't seem to exist yet.  This doesn't work:
    //_timestep_limiting_function = &_problem.getFunction(_timestep_limiting_function_name);
    _max_function_change = isParamValid("max_function_change") ?
        getParam<Real>("max_function_change") : -1;
    if (_max_function_change < 0.0)
    {
      mooseError("'max_function_change' must be specified and be greater than 0");
    }
  }
  else
  {
    if (isParamValid("max_function_change"))
    {
      mooseError("'timestep_limiting_function' must be used for 'max_function_change' to be used");
    }
  }

  const std::vector<Real> & sync_times = getParam<std::vector<Real> >("sync_times");
  for (unsigned int i(0); i<sync_times.size(); ++i)
  {
    std::pair<Real,SyncType> st_pair = std::make_pair(sync_times[i],SYNC);
    _sync_times.push_back(st_pair);
  }
  const std::vector<Real> & time = getParam<std::vector<Real> >("time_t");
  if (_use_time_ipol)
  {
    for (unsigned int i(0); i<time.size(); ++i)
    {
      std::pair<Real,SyncType> st_pair = std::make_pair(time[i],TIME_FUNC);
      _sync_times.push_back(st_pair);
    }
  }
  std::sort(_sync_times.begin(), _sync_times.end(),sortsyncpair);
  _curr_sync_time_iter = _sync_times.begin();

  // Advance to the first sync time if one is provided in sim time range
  while (_remaining_sync_time && _curr_sync_time_iter->first <= _time)
  {
    if (++_curr_sync_time_iter == _sync_times.end())
    {
      _remaining_sync_time = false;
    }
  }

  if (!_restart_file_base.empty())
    _problem.setRestartFile(_restart_file_base);

  setupTimeIntegrator();
}