Exemplo n.º 1
0
void
AStableDirk4::solve()
{
  // Reset iteration counts
  _n_nonlinear_iterations = 0;
  _n_linear_iterations = 0;

  if (_t_step == 1 && _safe_start)
  {
    _bootstrap_method->solve();
    _n_nonlinear_iterations = _bootstrap_method->getNumNonlinearIterations();
    _n_linear_iterations = _bootstrap_method->getNumLinearIterations();
  }
  else
  {
    // Time at end of step
    Real time_old = _fe_problem.timeOld();

    // A for-loop would increment _stage too far, so we use an extra
    // loop counter.  The method has three stages and an update stage,
    // which we treat as just one more (special) stage in the implementation.
    for (unsigned int current_stage = 1; current_stage < 5; ++current_stage)
    {
      // Set the current stage value
      _stage = current_stage;

      // This ensures that all the Output objects in the OutputWarehouse
      // have had solveSetup() called, and sets the default solver
      // parameters for PETSc.
      _fe_problem.initPetscOutput();

      if (current_stage < 4)
      {
        _console << "Stage " << _stage << "\n";
        _fe_problem.time() = time_old + _c[_stage - 1] * _dt;
      }
      else
      {
        _console << "Update Stage.\n";
        _fe_problem.time() = time_old + _dt;
      }

      // Do the solve
      _fe_problem.getNonlinearSystemBase().system().solve();

      // Update the iteration counts
      _n_nonlinear_iterations += getNumNonlinearIterationsLastSolve();
      _n_linear_iterations += getNumLinearIterationsLastSolve();

      // Abort time step immediately on stage failure - see TimeIntegrator doc page
      if (!_fe_problem.converged())
        return;
    }
  }
}
Exemplo n.º 2
0
void
ExplicitTVDRK2::solve()
{
  Real time_new = _fe_problem.time();
  Real time_old = _fe_problem.timeOld();
  Real time_stage2 = time_old + _dt;

  // Reset numbers of iterations
  _n_nonlinear_iterations = 0;
  _n_linear_iterations = 0;

  // There is no work to do for the first stage (Y_1 = y_n).  The
  // first solve therefore happens in the second stage.  Note that the
  // non-time Kernels (which should be marked implicit=false) are
  // evaluated at the old solution during this stage.
  _fe_problem.initPetscOutput();
  _console << "1st solve\n";
  _stage = 2;
  _fe_problem.timeOld() = time_old;
  _fe_problem.time() = time_stage2;
  _fe_problem.getNonlinearSystemBase().system().solve();
  _n_nonlinear_iterations += getNumNonlinearIterationsLastSolve();
  _n_linear_iterations += getNumLinearIterationsLastSolve();

  // Advance solutions old->older, current->old.  Also moves Material
  // properties and other associated state forward in time.
  _fe_problem.advanceState();

  // The "update" stage (which we call stage 3) requires an additional
  // solve with the mass matrix.
  _fe_problem.initPetscOutput();
  _console << "2nd solve\n";
  _stage = 3;
  _fe_problem.timeOld() = time_stage2;
  _fe_problem.time() = time_new;
  _fe_problem.getNonlinearSystemBase().system().solve();
  _n_nonlinear_iterations += getNumNonlinearIterationsLastSolve();
  _n_linear_iterations += getNumLinearIterationsLastSolve();

  // Reset time at beginning of step to its original value
  _fe_problem.timeOld() = time_old;
}