Feel++  0.91.4
Public Types | Public Member Functions
Feel::Aitken< fs_type > Class Template Reference

Aitken relaxation method for fixed point iterations. More...

#include <aitken2.hpp>

List of all members.

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_typeoperator++ ()
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 ()

Detailed Description

template<typename fs_type>
class Feel::Aitken< fs_type >

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;

   }

 *
Author:
Goncalo Pena
Christophe Prud'homme
Vincent Chabannes
 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;
 }
Author:
Vincent Chabannes

Member Typedef Documentation

template<typename fs_type >
typedef std::map<std::string, double> Feel::Aitken< fs_type >::convergence_iteration_type

convergence_iteration_type:

  • int: iteration number
  • double: residual 2-norm
  • double: computing time for the iteration

Constructor & Destructor Documentation

template<typename fs_type >
Feel::Aitken< fs_type >::Aitken ( functionspace_ptrtype  _Xh,
AitkenType  _aitkenType = AITKEN_STANDARD,
double  _failsafeParameter = 1.0,
double  _tol = 1.0e-6 
) [inline]

Constructor

template<typename fs_type >
Feel::Aitken< fs_type >::Aitken ( Aitken< fs_type > const &  tc) [inline]

copy constructor

template<typename fs_type >
Feel::Aitken< fs_type >::~Aitken ( ) [inline]

destructor

template<typename fs_type >
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.

Parameters:
_Xhthe function space from which the element will be used
_failsafeParameterfail safe parameter value
template<typename fs_type >
Feel::Aitken< fs_type >::Aitken ( Aitken< fs_type > const &  tc) [inline]

copy constructor

template<typename fs_type >
Feel::Aitken< fs_type >::~Aitken ( ) [inline]

destructor


Member Function Documentation

template<typename fs_type >
Feel::Aitken< fs_type >::BOOST_PARAMETER_MEMBER_FUNCTION ( (void)  ,
initialize  ,
tag  ,
(required(residual,*)(currentElt,*))   
) [inline]

initiliaze the aitken algorithm

template<typename fs_type >
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}

template<typename fs_type >
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}

template<typename fs_type >
double Feel::Aitken< fs_type >::calculateParameter ( )
Returns:
the Aitken parameter
template<typename fs_type >
void Feel::Aitken< fs_type >::initialize ( element_type const &  residual,
element_type const &  elem 
) [inline]

initiliaze the aitken algorithm

Parameters:
residualprevious residual
elemprevious element
template<typename fs_type >
uint Feel::Aitken< fs_type >::nIterations ( ) [inline]

get number of iterations

template<typename fs_type >
template<typename eltType >
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}

template<typename fs_type >
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.

template<typename fs_type >
void Feel::Aitken< fs_type >::relaxationStep ( element_type &  new_elem) [inline]

Do a relaxation step

Parameters:
new_elemnew element to compute the relaxation step
template<typename fs_type >
void Feel::Aitken< fs_type >::resetPreviousParameter ( ) [inline]

reset the previous parameter

template<typename fs_type >
void Feel::Aitken< fs_type >::restart ( )

reset the previous parameter

template<typename fs_type >
void Feel::Aitken< fs_type >::saveConvergenceHistory ( std::string const &  fname) const

save converegence history

Parameters:
fnamename of the file to save the convergence history
template<typename fs_type >
void Feel::Aitken< fs_type >::setElement ( element_type const &  residual,
element_type const &  elem 
) [inline]

Set the current element

Parameters:
residualcurrent residual
elemcurrent element
template<typename fs_type >
void Feel::Aitken< fs_type >::shiftRight ( ) [inline]

shift current step to previous step. After the call, we are ready for the next step.

template<typename fs_type >
void Feel::Aitken< fs_type >::shiftRight ( )

shift current step to previous step. After the call, we are ready for the next step.

template<typename fs_type >
double Feel::Aitken< fs_type >::theta ( ) [inline]

get theta

template<typename fs_type >
AitkenType Feel::Aitken< fs_type >::type ( ) const [inline]
Returns:
Aitken method type