Feel++
0.91.4
|
Aitken relaxation method for fixed point iterations. More...
#include <aitken2.hpp>
Public Types | |
typedef Aitken< fs_type > | self_type |
typedef fs_type | functionspace_type |
typedef boost::shared_ptr < functionspace_type > | functionspace_ptrtype |
typedef functionspace_type::element_type | element_type |
typedef functionspace_type::template Element< typename functionspace_type::value_type, typename VectorUblas< typename functionspace_type::value_type > ::range::type > | element_range_type |
typedef std::map< std::string, double > | convergence_iteration_type |
typedef std::map< int, convergence_iteration_type > | convergence_type |
typedef fs_type | functionspace_type |
typedef boost::shared_ptr < functionspace_type > | functionspace_ptrtype |
typedef functionspace_type::element_type | element_type |
typedef functionspace_type::template Element< typename functionspace_type::value_type, typename VectorUblas< typename functionspace_type::value_type > ::range::type > | element_range_type |
Public Member Functions | |
Aitken (functionspace_ptrtype _Xh, AitkenType _aitkenType=AITKEN_STANDARD, double _failsafeParameter=1.0, double _tol=1.0e-6) | |
Aitken (Aitken const &tc) | |
~Aitken () | |
BOOST_PARAMETER_MEMBER_FUNCTION ((void), initialize, tag,(required(residual,*)(currentElt,*))) | |
BOOST_PARAMETER_MEMBER_FUNCTION ((element_type), apply, tag,(required(residual,*)(currentElt,*))(optional(forceRelaxation,(bool), false))) | |
template<typename eltType > | |
element_type | operator() (element_type const &residual, eltType const &elem, bool _forceRelax=false) |
BOOST_PARAMETER_MEMBER_FUNCTION ((void), apply2, tag,(required(newElt,*)(residual,*)(currentElt,*))(optional(forceRelaxation,(bool), false))) | |
void | setType (AitkenType t) |
set Aitken method type | |
AitkenType | type () const |
void | shiftRight () |
self_type & | operator++ () |
void | restart () |
double | theta () |
uint | nIterations () |
bool | isFinished () |
double | residualNorm () |
void | printInfo () |
void | saveConvergenceHistory (std::string const &fname) const |
void | forceConvergence (bool b) |
Aitken (functionspace_ptrtype _Xh, double _failsafeParameter=0.1) | |
Aitken (Aitken const &tc) | |
~Aitken () | |
void | initialize (element_type const &residual, element_type const &elem) |
void | initialize (element_type const &residual, element_range_type const &elem) |
void | setElement (element_type const &residual, element_type const &elem) |
void | setElement (element_type const &residual, element_range_type const &elem) |
double | calculateParameter () |
void | relaxationStep (element_type &new_elem) |
void | shiftRight () |
void | resetPreviousParameter () |
Aitken relaxation method for fixed point iterations.
auto Xh = space_type::New(mesh); auto residual = Xh->element(); auto u_old->element(); auto u_new->element(); AitkenType relaxmethod = (AitkenType)this->vm()["relaxmethod"].as<int>(); Aitken<space_type> aitken( Xh, relaxmethod,init_theta, tol ); //where init_theta is the initial value of relaxation parameter // if relaxmethod=0(use the AITKEN_STANDARD method) // else if relaxmethod=1(use the AITKEN_METHOD_1 method) // relaxmethod=2(use the FIXED_RELAXATION_METHOD method) in this last case the relaxation parameter theta remains fixed during the itérations(theta = init_theta) and the particular case (init_theta=1) corresponds to the case without relaxation // initialize aitken aitken.initialize( residual, u_new ); aitken.restart(); while(!aitken.isFinished()) { u_old = u_new; commpute u_new; residual = u_new-u_old; u_new = aitken.apply(residual, u_new); aitken.printInfo(); ++aitken; } *
space_ptrtype Xh; space_type::element_type residual( Xh ); space_type::element_type u_old( Xh ); space_type::element_type u_new( Xh ); Aitken<space_type> aitken( Xh ); // initialize aitken aitken.initialize( residual, u_new ); // reset aitken parameter before entering the fixed point loop aitken.resetPreviousParameter(); // fixed point loop for( int i = 0; i < niter; ++i ) { // do some computation aitken.SetElement( residual, u_new ); theta = aitken.calculateParameter(); // exploit aitken relaxation parameter u = theta * u_new + (1-theta)* u_old; aitken.shiftRight(); u_old = u_new; }
typedef std::map<std::string, double> Feel::Aitken< fs_type >::convergence_iteration_type |
convergence_iteration_type:
Feel::Aitken< fs_type >::Aitken | ( | functionspace_ptrtype | _Xh, |
AitkenType | _aitkenType = AITKEN_STANDARD , |
||
double | _failsafeParameter = 1.0 , |
||
double | _tol = 1.0e-6 |
||
) | [inline] |
Constructor
Feel::Aitken< fs_type >::Aitken | ( | Aitken< fs_type > const & | tc | ) | [inline] |
copy constructor
Feel::Aitken< fs_type >::~Aitken | ( | ) | [inline] |
destructor
Feel::Aitken< fs_type >::Aitken | ( | functionspace_ptrtype | _Xh, |
double | _failsafeParameter = 0.1 |
||
) | [inline] |
Constructor
the _failsafeParameter
is set to 1 by default. The _failsafeParameter parameter provides an upper value for the relaxation parameter that will not be exceeded.
_Xh | the function space from which the element will be used |
_failsafeParameter | fail safe parameter value |
Feel::Aitken< fs_type >::Aitken | ( | Aitken< fs_type > const & | tc | ) | [inline] |
copy constructor
Feel::Aitken< fs_type >::~Aitken | ( | ) | [inline] |
destructor
Feel::Aitken< fs_type >::BOOST_PARAMETER_MEMBER_FUNCTION | ( | (void) | , |
initialize | , | ||
tag | , | ||
(required(residual,*)(currentElt,*)) | |||
) | [inline] |
initiliaze the aitken algorithm
Feel::Aitken< fs_type >::BOOST_PARAMETER_MEMBER_FUNCTION | ( | (element_type) | , |
apply | , | ||
tag | , | ||
(required(residual,*)(currentElt,*))(optional(forceRelaxation,(bool), false)) | |||
) | [inline] |
Compute theta and do a relaxation step : u^{n+1} = theta*u^{n+1} + (1-theta)*u^{n}
Feel::Aitken< fs_type >::BOOST_PARAMETER_MEMBER_FUNCTION | ( | (void) | , |
apply2 | , | ||
tag | , | ||
(required(newElt,*)(residual,*)(currentElt,*))(optional(forceRelaxation,(bool), false)) | |||
) | [inline] |
Compute theta and do a relaxation step : u^{n+1} = theta*u^{n+1} + (1-theta)*u^{n}
double Feel::Aitken< fs_type >::calculateParameter | ( | ) |
void Feel::Aitken< fs_type >::initialize | ( | element_type const & | residual, |
element_type const & | elem | ||
) | [inline] |
initiliaze the aitken algorithm
residual | previous residual |
elem | previous element |
uint Feel::Aitken< fs_type >::nIterations | ( | ) | [inline] |
get number of iterations
element_type Feel::Aitken< fs_type >::operator() | ( | element_type const & | residual, |
eltType const & | elem, | ||
bool | _forceRelax = false |
||
) | [inline] |
Compute theta and do a relaxation step : u^{n+1} = theta*u^{n+1} + (1-theta)*u^{n}
Aitken< fs_type >::self_type & Feel::Aitken< fs_type >::operator++ | ( | ) |
shift current step to previous step. After the call, we are ready for the next step.
void Feel::Aitken< fs_type >::relaxationStep | ( | element_type & | new_elem | ) | [inline] |
Do a relaxation step
new_elem | new element to compute the relaxation step |
void Feel::Aitken< fs_type >::resetPreviousParameter | ( | ) | [inline] |
reset the previous parameter
void Feel::Aitken< fs_type >::restart | ( | ) |
reset the previous parameter
void Feel::Aitken< fs_type >::saveConvergenceHistory | ( | std::string const & | fname | ) | const |
save converegence history
fname | name of the file to save the convergence history |
void Feel::Aitken< fs_type >::setElement | ( | element_type const & | residual, |
element_type const & | elem | ||
) | [inline] |
Set the current element
residual | current residual |
elem | current element |
void Feel::Aitken< fs_type >::shiftRight | ( | ) | [inline] |
shift current step to previous step. After the call, we are ready for the next step.
void Feel::Aitken< fs_type >::shiftRight | ( | ) |
shift current step to previous step. After the call, we are ready for the next step.
double Feel::Aitken< fs_type >::theta | ( | ) | [inline] |
get theta
AitkenType Feel::Aitken< fs_type >::type | ( | ) | const [inline] |