Exemplo n.º 1
0
void
AB2PredictorCorrector::step()
{
  NonlinearSystem & nl = _fe_problem.getNonlinearSystem();
  AuxiliarySystem & aux = _fe_problem.getAuxiliarySystem();

  _fe_problem.solve();
  _converged = _fe_problem.converged();
  if (_converged)
  {
    _u1 = *nl.currentSolution();
    _u1.close();

    _aux1 = *aux.currentSolution();
    _aux1.close();
    if (_t_step >= _start_adapting)
    {
      // Calculate error if past the first solve
      _error = estimateTimeError(_u1);

      _infnorm = _u1.linfty_norm();
      _e_max = 1.1 * _e_tol * _infnorm;
      _console << "Time Error Estimate: " << _error << std::endl;
    }
    else
    {
      //First time step is problematic, sure we converged but what does that mean? We don't know.
      //Nor can we calculate the error on the first time step.
    }
  }
}
Exemplo n.º 2
0
  Flag RosenbrockStationary::oneIteration(AdaptInfo& adaptInfo, Flag toDo)
  {
    Flag flag = 0, markFlag = 0;


    if (toDo.isSet(MARK))
      markFlag = problem->markElements(adaptInfo);
    else
      markFlag = 3;

    // refine
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_REFINED))
      flag = problem->refineMesh(adaptInfo);

    // coarsen
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_COARSENED))
      flag |= problem->coarsenMesh(adaptInfo);

    if (toDo.isSet(BUILD) || toDo.isSet(SOLVE))
    {
      flag = stageIteration(adaptInfo, toDo, true, true);
      estimateTimeError(adaptInfo);
    }

    if (toDo.isSet(ESTIMATE))
      problem->estimate(adaptInfo);

    return flag;
  }
Exemplo n.º 3
0
void
Transient::solveStep(Real input_dt)
{
  _dt_old = _dt;

  if (input_dt == -1.0)
    _dt = computeConstrainedDT();
  else
    _dt = input_dt;

  Real current_dt = _dt;

  _problem.onTimestepBegin();

  // Increment time
  _time = _time_old + _dt;

  _problem.execTransfers(EXEC_TIMESTEP_BEGIN);
  _problem.execMultiApps(EXEC_TIMESTEP_BEGIN, _picard_max_its == 1);

  preSolve();
  _time_stepper->preSolve();

  _problem.timestepSetup();

  // Compute Pre-Aux User Objects (Timestep begin)
  _problem.computeUserObjects(EXEC_TIMESTEP_BEGIN, UserObjectWarehouse::PRE_AUX);

  // Compute TimestepBegin AuxKernels
  _problem.computeAuxiliaryKernels(EXEC_TIMESTEP_BEGIN);

  // Compute Post-Aux User Objects (Timestep begin)
  _problem.computeUserObjects(EXEC_TIMESTEP_BEGIN, UserObjectWarehouse::POST_AUX);

  // Perform output for timestep begin
  _problem.outputStep(EXEC_TIMESTEP_BEGIN);

  if (_picard_max_its > 1)
  {
    Real current_norm = _problem.computeResidualL2Norm();
    if (_picard_it == 0) // First Picard iteration - need to save off the initial nonlinear residual
    {
      _picard_initial_norm = current_norm;
      _console << "Initial Picard Norm: " << _picard_initial_norm << '\n';
    }
    else
      _console << "Current Picard Norm: " << current_norm << '\n';

    Real relative_drop = current_norm / _picard_initial_norm;

    if (current_norm < _picard_abs_tol || relative_drop < _picard_rel_tol)
    {
      _console << "Picard converged!" << std::endl;

      _picard_converged = true;
      _time_stepper->acceptStep();
      return;
    }
  }

  _time_stepper->step();

  // We know whether or not the nonlinear solver thinks it converged, but we need to see if the executioner concurs
  if (lastSolveConverged())
  {
    _console << COLOR_GREEN << " Solve Converged!" << COLOR_DEFAULT << std::endl;

    if (_picard_max_its <= 1)
      _time_stepper->acceptStep();

    _solution_change_norm = _problem.solutionChangeNorm();

    _problem.computeUserObjects(EXEC_TIMESTEP_END, UserObjectWarehouse::PRE_AUX);
#if 0
    // User definable callback
    if (_estimate_error)
      estimateTimeError();
#endif

    _problem.onTimestepEnd();

    _problem.computeAuxiliaryKernels(EXEC_TIMESTEP_END);
    _problem.computeUserObjects(EXEC_TIMESTEP_END, UserObjectWarehouse::POST_AUX);
    _problem.execTransfers(EXEC_TIMESTEP_END);
    _problem.execMultiApps(EXEC_TIMESTEP_END, _picard_max_its == 1);
  }
  else
  {
    _console << COLOR_RED << " Solve Did NOT Converge!" << COLOR_DEFAULT << std::endl;

    // Perform the output of the current, failed time step (this only occurs if desired)
    _problem.outputStep(EXEC_FAILED);
  }

  postSolve();
  _time_stepper->postSolve();
  _dt = current_dt; // _dt might be smaller than this at this point for multistep methods
  _time = _time_old;
}
Exemplo n.º 4
0
void
Transient::takeStep(Real input_dt)
{
  _problem.out().setOutput(false);

  _dt_old = _dt;

  if (input_dt == -1.0)
    _dt = computeConstrainedDT();
  else
    _dt = input_dt;

  _problem.onTimestepBegin();
  if (lastSolveConverged())
    _problem.updateMaterials();             // Update backward material data structures

  // Increment time
  _time = _time_old + _dt;

  _problem.execTransfers(EXEC_TIMESTEP_BEGIN);
  _problem.execMultiApps(EXEC_TIMESTEP_BEGIN);

  // Only print this if the 'Output' block exists
  /// \todo{Remove when old output system is removed}
  if (_app.hasLegacyOutput())
  {
    Moose::out << "\nTime Step ";
    {
      std::ostringstream out;

      out << std::setw(2)
          << _t_step
          << ", time = "
          << std::setw(9)
          << std::setprecision(6)
          << std::setfill('0')
          << std::showpoint
          << std::left
          << _time;
      Moose::out << out.str() << std::endl;
    }

    {
      std::ostringstream tstepstr;
      tstepstr << _t_step;
      unsigned int tsteplen = tstepstr.str().size();
      if (tsteplen < 2)
        tsteplen = 2;

      std::ostringstream out;

      if (_verbose)
      {
        out << std::setw(tsteplen)
            << "          old time = "
            << std::setw(9)
            << std::setprecision(6)
            << std::setfill('0')
            << std::showpoint
            << std::left
            << _time_old
            << std::endl;
      }

      out << std::setw(tsteplen)
          <<"                dt = "
          << std::setw(9)
          << std::setprecision(6)
          << std::setfill('0')
          << std::showpoint
          << std::left
          << _dt;

      Moose::out << out.str() << std::endl;
    }
  }

  preSolve();
  _time_stepper->preSolve();

  _problem.timestepSetup();

  // Compute Pre-Aux User Objects (Timestep begin)
  _problem.computeUserObjects(EXEC_TIMESTEP_BEGIN, UserObjectWarehouse::PRE_AUX);

  // Compute TimestepBegin AuxKernels
  _problem.computeAuxiliaryKernels(EXEC_TIMESTEP_BEGIN);

  // Compute Post-Aux User Objects (Timestep begin)
  _problem.computeUserObjects(EXEC_TIMESTEP_BEGIN, UserObjectWarehouse::POST_AUX);

  _time_stepper->step();

  // We know whether or not the nonlinear solver thinks it converged, but we need to see if the executioner concurs
  if (lastSolveConverged())
  {
    Moose::out << "Solve Converged!" << std::endl;

    _time_stepper->acceptStep();

    _solution_change_norm = _problem.solutionChangeNorm();

    _problem.computeUserObjects(EXEC_TIMESTEP, UserObjectWarehouse::PRE_AUX);
#if 0
    // User definable callback
    if (_estimate_error)
    {
      estimateTimeError();
    }
#endif

    _problem.onTimestepEnd();

    _problem.computeAuxiliaryKernels(EXEC_TIMESTEP);
    _problem.computeUserObjects(EXEC_TIMESTEP, UserObjectWarehouse::POST_AUX);
    _problem.execTransfers(EXEC_TIMESTEP);
    _problem.execMultiApps(EXEC_TIMESTEP);
  }
  else
    Moose::out << "Solve Did NOT Converge!" << std::endl;

  postSolve();
  _time_stepper->postSolve();
}