示例#1
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
  }
}
示例#2
0
void LSSAction::on_regions_set()
{
  if(m_implementation->m_updating) // avoid recursion
    return;

  m_implementation->m_lss = options().value< Handle<LSS::System> >("lss");
  if(is_null(m_implementation->m_lss))
    return;

  if(is_null(m_dictionary))
    return;

  m_implementation->m_updating = true;

  // Create the LSS if the mesh is set
  if(!m_loop_regions.empty() && !m_implementation->m_lss->is_created())
  {
    VariablesDescriptor& descriptor = find_component_with_tag<VariablesDescriptor>(physical_model().variable_manager(), solution_tag());

    Handle< List<Uint> > gids = m_implementation->m_lss->create_component< List<Uint> >("GIDs");
    Handle< List<Uint> > ranks = m_implementation->m_lss->create_component< List<Uint> >("Ranks");
    Handle< List<Uint> > used_node_map = m_implementation->m_lss->create_component< List<Uint> >("used_node_map");

    std::vector<Uint> node_connectivity, starting_indices;
    boost::shared_ptr< List<Uint> > used_nodes = build_sparsity(m_loop_regions, *m_dictionary, node_connectivity, starting_indices, *gids, *ranks, *used_node_map);
    add_component(used_nodes);

    // This comm pattern is valid only over the used nodes for the supplied regions
    PE::CommPattern& comm_pattern = *create_component<PE::CommPattern>("CommPattern");
    comm_pattern.insert("gid",gids->array(),false);
    comm_pattern.setup(Handle<PE::CommWrapper>(comm_pattern.get_child("gid")),ranks->array());

    CFdebug << "Creating LSS for " << starting_indices.size()-1 << " blocks with descriptor " << solution_tag() << ": " << descriptor.description() << CFendl;
    m_implementation->m_lss->create(comm_pattern, descriptor.size(), node_connectivity, starting_indices);
    CFdebug << "Finished creating LSS" << CFendl;
    configure_option_recursively(solver::Tags::regions(), options().option(solver::Tags::regions()).value());
    configure_option_recursively("lss", m_implementation->m_lss);
  }

  // Update the regions of any owned initial conditions
  BOOST_FOREACH(const Handle<Component>& ic, m_created_initial_conditions)
  {
    ic->options().set(solver::Tags::regions(), options().option(solver::Tags::regions()).value());
  }
示例#3
0
void FaceTerm::link_fields()
{
  if( is_null( m_solution ) )
  {
    m_solution = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::solution() ))->handle<Field>();
    configure_option_recursively( RDM::Tags::solution(), m_solution );
  }

  if( is_null( m_residual ) )
  {
    m_residual = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::residual() ))->handle<Field>();
    configure_option_recursively( RDM::Tags::residual(), m_residual );
  }

  if( is_null( m_wave_speed ) )
  {
    m_wave_speed = follow_link( solver().handle<RDM::RDSolver>()->fields().get_child( RDM::Tags::wave_speed() ))->handle<Field>();
    configure_option_recursively( RDM::Tags::wave_speed(), m_wave_speed );
  }
}
示例#4
0
void Term::link_fields()
{
  if( is_null( m_solution.lock() ) )
  {
    m_solution = solver().field_manager()
                         .get_child( SFDM::Tags::solution() ).follow()->as_ptr_checked<Field>();
    configure_option_recursively( SFDM::Tags::solution(), m_solution.lock()->uri() );
  }

  if( is_null( m_residual.lock() ) )
  {
    m_residual = solver().field_manager()
                         .get_child( SFDM::Tags::residual() ).follow()->as_ptr_checked<Field>();
    configure_option_recursively( SFDM::Tags::residual(), m_residual.lock()->uri() );
  }

  if( is_null( m_wave_speed.lock() ) )
  {
    m_wave_speed = solver().field_manager()
                           .get_child( SFDM::Tags::wave_speed() ).follow()->as_ptr_checked<Field>();
    configure_option_recursively( SFDM::Tags::wave_speed(), m_wave_speed.lock()->uri() );
  }

  if( is_null( m_jacob_det.lock() ) )
  {
    m_jacob_det = solver().field_manager()
                          .get_child( SFDM::Tags::jacob_det() ).follow()->as_ptr_checked<Field>();
    configure_option_recursively( SFDM::Tags::jacob_det(), m_jacob_det.lock()->uri() );
  }

  if( is_null( m_field_group.lock() ) )
  {
    m_field_group = solution().field_group().as_ptr<FieldGroup>();
  }

}
示例#5
0
void PrepareMesh::execute()
{
  // configuration of all solver components.
  // This component and its children should be part of it.
  solver().configure_option_recursively(sdm::Tags::solution_order(),solver().options().option(sdm::Tags::solution_order()).value<Uint>());
  solver().configure_option_recursively(sdm::Tags::mesh(),mesh().handle<Component>());
  solver().configure_option_recursively(sdm::Tags::regions(),solver().options().option(sdm::Tags::regions()).value< std::vector<URI> >());
  solver().configure_option_recursively(sdm::Tags::physical_model(),physical_model().handle<Component>());
  solver().configure_option_recursively(sdm::Tags::solver(),solver().handle<Component>());

  configure_option_recursively(sdm::Tags::solution_order(),solver().options().option(sdm::Tags::solution_order()).value<Uint>());
  configure_option_recursively(sdm::Tags::mesh(),mesh().handle<Component>());
  configure_option_recursively(sdm::Tags::regions(),solver().options().option(sdm::Tags::regions()).value< std::vector<URI> >());
  configure_option_recursively(sdm::Tags::physical_model(),physical_model().handle<Component>());
  configure_option_recursively(sdm::Tags::solver(),solver().handle<Component>());

  // execution of prepare mesh
  ActionDirector::execute();

  std::vector<URI> fields;
  fields.push_back( follow_link( solver().field_manager().get_child(sdm::Tags::solution()) )->uri() );
  solver().handle<SDSolver>()->time_stepping().post_actions().get_child("Periodic")->configure_option_recursively("fields",fields);
  solver().handle<SDSolver>()->time_stepping().post_actions().get_child("Periodic")->configure_option_recursively("file",URI("sdm_output_${time}.msh"));
}
示例#6
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

  }
}