Пример #1
0
IterativeSolver::IterativeSolver ( const std::string& name ) :
  CF::Solver::ActionDirector(name)
{
  mark_basic();

  // properties

  m_properties.add_property( "iteration", Uint(0) );

  // static components

  m_pre_actions  = create_static_component_ptr<CActionDirector>("PreActions");

  m_update = create_static_component_ptr<CActionDirector>("Update");

  m_post_actions = create_static_component_ptr<CActionDirector>("PostActions");

  // dynamic components

  create_component<CCriterionMaxIterations>( "MaxIterations" );

  CComputeLNorm& cnorm = post_actions().create_component<CComputeLNorm>( "ComputeNorm" );
  post_actions().append( cnorm );

  CPeriodicWriteMesh& cwriter = post_actions().create_component<CPeriodicWriteMesh>( "PeriodicWriter" );
  post_actions().append( cwriter );

  cnorm.configure_option("Scale", true);
  cnorm.configure_option("Order", 2u);
}
Пример #2
0
IterativeSolver::IterativeSolver ( const std::string& name ) :
  cf3::solver::ActionDirector(name)
{
  mark_basic();

  // properties

  properties().add( "iteration", Uint(0) );

  // static components

  m_pre_actions  = create_static_component<ActionDirector>("PreActions");

  m_update = create_static_component<ActionDirector>("Update");

  m_post_actions = create_static_component<ActionDirector>("PostActions");

  // dynamic components

  create_component<CriterionMaxIterations>( "MaxIterations" );

  ComputeLNorm& cnorm = *post_actions().create_component<ComputeLNorm>( "ComputeNorm" );
  post_actions().create_component<PrintIterationSummary>( "IterationSummary" );
  post_actions().create_component<PeriodicWriteMesh>( "PeriodicWriter" );

  cnorm.options().set("scale", true);
  cnorm.options().set("order", 2u);
}
Пример #3
0
void IterativeSolver::execute()
{
  RDM::RDSolver& mysolver = *solver().handle< RDM::RDSolver >();

  /// @todo this configuration sould be in constructor but does not work there

  configure_option_recursively( "iterator", handle<Component>() );

  // access components (out of loop)

  ActionDirector& boundary_conditions =
      *access_component( "cpath:../BoundaryConditions" )->handle<ActionDirector>();

  ActionDirector& domain_discretization =
      *access_component( "cpath:../DomainDiscretization" )->handle<ActionDirector>();

  Action& synchronize = *mysolver.actions().get_child("Synchronize")->handle<Action>();

  Handle<Component> cnorm = post_actions().get_child("ComputeNorm");
  cnorm->options().set("table", follow_link(mysolver.fields().get_child( RDM::Tags::residual() ))->uri() );

  Component& cprint = *post_actions().get_child("IterationSummary");
  cprint.options().set("norm", cnorm );

  // iteration loop

  Uint iter = 1; // iterations start from 1 ( max iter zero will do nothing )
  properties().property("iteration") = iter;


  while( ! stop_condition() ) // non-linear loop
  {
    // (1) the pre actions - cleanup residual, pre-process something, etc
    pre_actions().execute();

    // (2) domain discretization
    domain_discretization.execute();

    // (3) apply boundary conditions
    boundary_conditions.execute();

    // (4) update
    update().execute();

    // (5) update
    synchronize.execute();

    // (6) the post actions - compute norm, post-process something, etc
    post_actions().execute();

    // raise signal that iteration is done
    raise_iteration_done();

    // increment iteration
    properties().property("iteration") = ++iter; // update the iteration number
  }
}
Пример #4
0
void IterativeSolver::execute()
{
  RDM::RDSolver& mysolver = solver().as_type< RDM::RDSolver >();

  /// @todo this configuration sould be in constructor but does not work there

  configure_option_recursively( "iterator", this->uri() );

  // access components (out of loop)

  CActionDirector& boundary_conditions =
      access_component( "cpath:../BoundaryConditions" ).as_type<CActionDirector>();

  CActionDirector& domain_discretization =
      access_component( "cpath:../DomainDiscretization" ).as_type<CActionDirector>();

  CAction& synchronize = mysolver.actions().get_child("Synchronize").as_type<CAction>();

  Component& cnorm = post_actions().get_child("ComputeNorm");
  cnorm.configure_option("Field", mysolver.fields().get_child( RDM::Tags::residual() ).follow()->uri() );

  // iteration loop

  Uint iter = 1; // iterations start from 1 ( max iter zero will do nothing )
  property("iteration") = iter;


  while( ! stop_condition() ) // non-linear loop
  {
    // (1) the pre actions - cleanup residual, pre-process something, etc

    pre_actions().execute();

    // (2) domain discretization

    domain_discretization.execute();

    // (3) apply boundary conditions

    boundary_conditions.execute();

    // (4) update

    update().execute();

    // (5) update

    synchronize.execute();

    // (6) the post actions - compute norm, post-process something, etc

    post_actions().execute();

    // output convergence info

    /// @todo move current rhs as a prpoerty of the iterate or solver components
    if( Comm::PE::instance().rank() == 0 )
    {
      Real rhs_norm = cnorm.properties().value<Real>("Norm");
      CFinfo << "iter ["    << std::setw(4)  << iter << "]"
             << "L2(rhs) [" << std::setw(12) << rhs_norm << "]" << CFendl;

      if ( is_nan(rhs_norm) || is_inf(rhs_norm) )
        throw FailedToConverge(FromHere(),
                               "Solution diverged after "+to_str(iter)+" iterations");
    }

    // raise signal that iteration is done

    raise_iteration_done();

    // increment iteration

    property("iteration") = ++iter; // update the iteration number

  }
}