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 } }
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 } }