void Godunov::MultiPhase(const double & CFL, unsigned phase) {
	double t = 0;
	Cell leftCell;
	Cell rightCell;
	bool phaseInteraction;
	while (t < getMax()) {
		BoundaryConditions();
		for (unsigned i = 0; i < getCell().size(); ++i) {
            phaseInteraction = false;
			leftCell = getCell()[i % getCell().size()];
			rightCell = getCell()[(i + 1) % getCell().size()];
			if (i == getCell().size() - 2)
				continue;
			for (unsigned j = 0; j < phase; ++j)
				if (leftCell.getPhase()[j].getPhi()
						!= rightCell.getPhase()[j].getPhi()) {
					phaseInteraction = true;
					break;
				}
			if (!phaseInteraction) {
				for (unsigned j = 0; j < phase; ++j)
					detachedRiemann(leftCell, rightCell, i, j);
			}
		}
		computeDT(CFL);
		timeIntegration();
		for (unsigned i = 0; i < getCell().size(); ++i) {
			setCell()[i].computeScalFromCons();
		}
		t += getDt();
	}
}
Example #2
0
void
Transient::execute()
{
  preExecute();

  // NOTE: if you remove this line, you will see a subset of tests failing. Those tests might have a wrong answer and might need to be regolded.
  // The reason is that we actually move the solution back in time before we actually start solving (which I think is wrong).  So this call here
  // is to maintain backward compatibility and so that MOOSE is giving the same answer.  However, we might remove this call and regold the test
  // in the future eventually.
  if (!_app.isRecovering())
    _problem.copyOldSolutions();

  // Start time loop...
  while (true)
  {
    if (_first != true)
      incrementStepOrReject();

    _first = false;

    if (!keepGoing())
      break;

    computeDT();
    takeStep();
    endStep();

    _steps_taken++;
  }


  postExecute();
}
Example #3
0
Real
PostprocessorDT::computeInitialDT()
{
  if (_has_initial_dt)
    return _initial_dt;
  else
    return computeDT();
}
void Godunov::Solve(const double& CFL) {
	//dt_ = 0.00005;
	computeDT(CFL);
	if (getCell()[0].getPhase().size() == 1)
		SinglePhase(CFL);
	else
		MultiPhase(CFL, getCell()[0].getPhase().size());
	BoundaryConditions();
}
Example #5
0
void
Transient::init()
{
  if (!_time_stepper.get())
  {
    InputParameters pars = _app.getFactory().getValidParams("ConstantDT");
    pars.set<FEProblem *>("_fe_problem") = &_problem;
    pars.set<Transient *>("_executioner") = this;

    /**
     * We have a default "dt" set in the Transient parameters but it's possible for users to set other
     * parameters explicitly that could provide a better calculated "dt". Rather than provide difficult
     * to understand behavior using the default "dt" in this case, we'll calculate "dt" properly.
     */
    if (!_pars.isParamSetByAddParam("end_time") && !_pars.isParamSetByAddParam("num_steps") && _pars.isParamSetByAddParam("dt"))
      pars.set<Real>("dt") = (getParam<Real>("end_time") - getParam<Real>("start_time")) / static_cast<Real>(getParam<unsigned int>("num_steps"));
    else
      pars.set<Real>("dt") = getParam<Real>("dt");

    pars.set<bool>("reset_dt") = getParam<bool>("reset_dt");
    _time_stepper = MooseSharedNamespace::static_pointer_cast<TimeStepper>(_app.getFactory().create("ConstantDT", "TimeStepper", pars));
  }

  _problem.initialSetup();
  _time_stepper->init();

  if (_app.isRestarting())
    _time_old = _time;

  Moose::setup_perf_log.push("Output Initial Condition","Setup");
  _problem.outputStep(EXEC_INITIAL);
  Moose::setup_perf_log.pop("Output Initial Condition","Setup");

  // If this is the first step
  if (_t_step == 0)
    _t_step = 1;

  if (_t_step > 1) //Recover case
    _dt_old = _dt;

  else
  {
    computeDT();
//  _dt = computeConstrainedDT();
    _dt = getDT();
  }


}
Example #6
0
void
Transient::init()
{
  if (_time_stepper == NULL)
  {
    InputParameters pars = _app.getFactory().getValidParams("ConstantDT");
    pars.set<FEProblem *>("_fe_problem") = &_problem;
    pars.set<Transient *>("_executioner") = this;
    pars.set<Real>("dt") = getParam<Real>("dt");
    pars.set<bool>("reset_dt") = getParam<bool>("reset_dt");
    _time_stepper = static_cast<TimeStepper *>(_app.getFactory().create("ConstantDT", "TimeStepper", pars));
  }

  _problem.initialSetup();
  _time_stepper->init();

  Moose::setup_perf_log.push("Output Initial Condition","Setup");

  _output_warehouse.outputInitial();

  if (_output_initial)
  {
    _problem.output();
    _problem.outputPostprocessors();
    _problem.outputRestart();
  }
  Moose::setup_perf_log.pop("Output Initial Condition","Setup");

  // If this is the first step
  if (_t_step == 0)
    _t_step = 1;

  if (_t_step > 1) //Restart case
  {
    _dt_old = _dt;
  }
  else
  {
    computeDT();
//  _dt = computeConstrainedDT();
    _dt = getDT();
  }
}
Example #7
0
void
TimeStepper::computeStep()
{
  if (_t_step < 2 || (_reset_dt && !_has_reset_dt))
  {
    _has_reset_dt = true;

    if (converged())
      _current_dt = computeInitialDT();
    else
      _current_dt = computeFailedDT();
  }
  else
  {
    if (converged())
      _current_dt = computeDT();
    else
      _current_dt = computeFailedDT();
  }
}
Example #8
0
void PostdominatorTree::analyze(ir::IRKernel& kernel) {
    // form a vector of the basic blocks in post-order
    report("Building post-dominator tree.");
    cfg = kernel.cfg();
    report(" Starting with post order sequence");
    // form a vector of the basic blocks in post-order
    ir::ControlFlowGraph::BlockPointerVector
    post_order = cfg->reverse_topological_sequence();

    ir::ControlFlowGraph::reverse_pointer_iterator it = post_order.rbegin();
    ir::ControlFlowGraph::reverse_pointer_iterator end = post_order.rend();
    for (; it != end; ++it) {
        blocks.push_back(*it);
        blocksToIndex[*it] = (int)blocks.size()-1;
        p_dom.push_back(-1);
        report("  " << (*it)->label());
    }

    computeDT();
}
Example #9
0
void
Transient::init()
{
  if (!_time_stepper.get())
  {
    InputParameters pars = _app.getFactory().getValidParams("ConstantDT");
    pars.set<FEProblem *>("_fe_problem") = &_problem;
    pars.set<Transient *>("_executioner") = this;
    pars.set<Real>("dt") = getParam<Real>("dt");
    pars.set<bool>("reset_dt") = getParam<bool>("reset_dt");
    _time_stepper = MooseSharedNamespace::static_pointer_cast<TimeStepper>(_app.getFactory().create("ConstantDT", "TimeStepper", pars));
  }

  _problem.initialSetup();
  _time_stepper->init();

  if (_app.isRestarting())
    _time_old = _time;

  Moose::setup_perf_log.push("Output Initial Condition","Setup");
  _problem.outputStep(EXEC_INITIAL);
  Moose::setup_perf_log.pop("Output Initial Condition","Setup");

  // If this is the first step
  if (_t_step == 0)
    _t_step = 1;

  if (_t_step > 1) //Recover case
    _dt_old = _dt;

  else
  {
    computeDT();
//  _dt = computeConstrainedDT();
    _dt = getDT();
  }


}
void Godunov::SinglePhase(const double & CFL) {
	double t = 0;
	while (t < getMax()) {
		BoundaryConditions();
		for (unsigned i = 0; i < getCell().size(); ++i) {
			if (i == getCell().size() - 2)
				continue;
			RiemannSolver riemann(getCell()[i % getCell().size()],
					getCell()[(i + 1) % getCell().size()], 1);
			riemann.solve();
			riemann.phase_star_[0].Sample(0, setCell()[i].setPhase()[0].setU_half(),
					setCell()[i].setPhase()[0].setP_half(),
					setCell()[i].setPhase()[0].setD_half(), riemann.phase_star_[0].pstar[0]
                                                          , riemann.phase_star_[0].ustar[0]);
			setCell()[i].setPhase()[0].InterCellFlux();
		}
		computeDT(CFL);
		timeIntegration();
		for (unsigned i = 0; i < getCell().size(); ++i) {
			setCell()[i].setPhase()[0].computeScalFromCons();
		}
		t += getDt();
	}
}
Example #11
0
Real
FunctionDT::computeInitialDT()
{
  return computeDT();
}
Example #12
0
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;

}