Gaudi Framework, version v20r4

Generated: 8 Jan 2009

EqSolver Class Reference

#include <EqSolver.h>

Inheritance diagram for EqSolver:

Inheritance graph
[legend]
Collaboration diagram for EqSolver:

Collaboration graph
[legend]

List of all members.


Detailed Description

The simplest concrete implementation of IEqSolver interface.

See also:
GaudiGSL/IEqSolver.h
Author:
Kirill Miklyaev kirillm@iris1.itep.ru
Date:
2003-07-07

Definition at line 28 of file EqSolver.h.


Public Types

typedef std::vector< EquationsJacobi

Public Member Functions

virtual StatusCode solver (const Equations &funcs, Arg &arg) const
 Solving nonlinear systemwith N equations in N unknowns of the function "GenFunc".
virtual StatusCode initialize ()
 Overriding initialize.
virtual StatusCode finalize ()
 standard finalization method
virtual ~EqSolver ()
 Destructor.
 EqSolver (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor.

Private Member Functions

 EqSolver ()
 default constructor is private
 EqSolver (const EqSolver &)
 copy constructor is private
EqSolveroperator= (const EqSolver &)
 assignement operator is

Private Attributes

std::string m_algType
double m_max_iter
double m_norm_residual
const
gsl_multiroot_fdfsolver_type * 
m_type
 AlgTool type (concrete class name).

Friends

class ToolFactory< EqSolver >

Classes

class  EqSolverMisc

Member Typedef Documentation

typedef std::vector<Equations> EqSolver::Jacobi

Definition at line 35 of file EqSolver.h.


Constructor & Destructor Documentation

EqSolver::~EqSolver (  )  [virtual]

Destructor.

Definition at line 344 of file EqSolver.cpp.

00345 {}

EqSolver::EqSolver ( const std::string &  type,
const std::string &  name,
const IInterface parent 
)

Standard constructor.

See also:
GaudiTool
Parameters:
type tool type
name tool name
parent parent of the tool

declare my special interface

declare type of the algorithm for root finding

declare maximum of iteration

declare the absolute error bound for the residual value

Definition at line 75 of file EqSolver.cpp.

00078   : GaudiTool       ( type, name , parent )
00079   , m_algType       ( "fdfsolver_hybridsj" ) 
00080   , m_max_iter      ( 1000                 ) 
00081   , m_norm_residual ( 1.0e-7               )
00082   , m_type          ( 0                    )
00083   
00084 {
00086   declareInterface <IEqSolver>(this);
00088   declareProperty ( "Algorithm", m_algType       );
00090   declareProperty ( "Iteration", m_max_iter      );
00092   declareProperty ( "Residual" , m_norm_residual );
00093 }

EqSolver::EqSolver (  )  [private]

default constructor is private

EqSolver::EqSolver ( const EqSolver  )  [private]

copy constructor is private


Member Function Documentation

StatusCode EqSolver::solver ( const Equations funcs,
Arg arg 
) const [virtual]

Solving nonlinear systemwith N equations in N unknowns of the function "GenFunc".

Solving nonlinear system of the function "GenFunc".

See also:
IEqSolver.h
Returns:
StatusCode

Definition at line 193 of file EqSolver.cpp.

00196 {
00197   using namespace Genfun;
00198     
00199   gsl_vector_view vect = gsl_vector_view_array ( &arg[0] ,
00200                                                  arg.dimension() );
00201   MsgStream log( msgSvc(), name() );
00202   
00203   EqSolverMisc local (funcs, arg);
00204 
00205   const gsl_multiroot_fdfsolver_type *T = m_type;
00206   gsl_multiroot_fdfsolver *s;
00207   int    status = 0 ;
00208   size_t iter   = 0 ;
00209 
00210   gsl_multiroot_function_fdf function;
00211   
00212   function.f = &fun_gsl;
00213   function.df = &dfun_gsl;
00214   function.fdf = &fdfun_gsl;
00215   function.n = vect.vector.size;
00216   function.params = (void*) &local;
00217 
00218   s = gsl_multiroot_fdfsolver_alloc(T, vect.vector.size);
00219   gsl_multiroot_fdfsolver_set (s, &function, &vect.vector);
00220    
00221   for (iter = 0; iter < m_max_iter; ++iter)
00222     {
00223       status = gsl_multiroot_fdfsolver_iterate (s);
00224       if (status)
00225         {
00226           return Error 
00227             ("Error from gsl_gsl_multiroot_fdfsolver_iterate '"
00228              + std::string(gsl_strerror(status)) + "'") ;
00229           break;
00230         }
00231   
00232       status = gsl_multiroot_test_residual (s->f, 
00233                                             m_norm_residual);
00234       
00235       if ( status != GSL_CONTINUE ) { break; }
00236     }
00237   
00238   for (unsigned int i = 0; i < vect.vector.size; ++i)
00239     {
00240       gsl_vector_set (&vect.vector, i, gsl_vector_get (s->x, i));
00241     }
00242   
00243   if (status == GSL_SUCCESS)
00244     {
00245       log << MSG::DEBUG 
00246           << "We stopped in the method on the " << iter 
00247           << " iteration (we have maximum "     << m_max_iter 
00248           << " iterations)"                     << endreq;
00249     }
00250   else if (status == GSL_CONTINUE && iter <= m_max_iter )
00251     {
00252       return Error ( "Method finished with '" 
00253                      + std::string(gsl_strerror(status)) 
00254                      +  "' error" );
00255     }
00256   else
00257     {
00258       return Error ( "Method finished with '" +
00259                      std::string(gsl_strerror(status)) 
00260                      +  "' error" );
00261     }
00262   
00263   gsl_multiroot_fdfsolver_free (s);
00264   
00265   if (status) 
00266     { 
00267       return Error ( "Method finished with '" 
00268                      + std::string(gsl_strerror(status)) 
00269                      +  "' error" );
00270     }
00271   
00272   return GSL_SUCCESS;
00273 }

StatusCode EqSolver::initialize (  )  [virtual]

Overriding initialize.

Reimplemented from GaudiTool.

Definition at line 276 of file EqSolver.cpp.

00278 {
00279   StatusCode sc = GaudiTool::initialize() ;
00280   
00281   MsgStream log( msgSvc() , name() ) ;
00282   
00283   if( sc.isFailure() ) 
00284     {
00285       return Error ("Could not initiliaze base class GaudiTool", sc);
00286     }
00287   /* The algorithm for multiional root-finding 
00288      (solving nonlinear systems with n equations in n unknowns)*/
00289   
00290   if(       "fdfsolver_hybridsj" == m_algType )
00291     {
00292       m_type = gsl_multiroot_fdfsolver_hybridsj  ;
00293       log << MSG::DEBUG 
00294           << "Root findind algoritms to be used: " 
00295           << "'gsl_multiroot_fdfsolver_hybridsj'" 
00296           << endreq;
00297     }
00298   else if ( "fdfsolver_hybridj" == m_algType ) 
00299     {
00300       m_type = gsl_multiroot_fdfsolver_hybridj   ;
00301       log << MSG::DEBUG 
00302           << "Root findind algoritms to be used: " 
00303           << "'gsl_multiroot_fdfsolver_hybridj'"
00304           << endreq;
00305     }
00306   else if ( "fdfsolver_newton" == m_algType )
00307     {
00308       m_type = gsl_multiroot_fdfsolver_newton    ;
00309       log << MSG::DEBUG 
00310           << "Root findind algoritms to be used: " 
00311           << "'gsl_multiroot_fdfsolver_newton'"
00312           << endreq;
00313     }
00314   else if ( "fdfsolver_gnewton" == m_algType )
00315     {
00316       m_type = gsl_multiroot_fdfsolver_gnewton   ;
00317       log << MSG::DEBUG 
00318           << "Root findind algoritms to be used: " 
00319           << "'gsl_multiroot_fdfsolver_gnewton'"
00320           << endreq;
00321     }
00322   else 
00323     {
00324       return Error(" Unknown algorith type '" 
00325                    + std::string(m_algType) + "'");
00326      }
00327   
00328   return StatusCode::SUCCESS;
00329 }  

StatusCode EqSolver::finalize ( void   )  [virtual]

standard finalization method

See also:
AlgTool

IAlgTool

Returns:
status code

Reimplemented from GaudiTool.

Definition at line 331 of file EqSolver.cpp.

00332 {
00333   StatusCode sc = GaudiTool::finalize() ;
00334   
00335   MsgStream log( msgSvc() , name() ) ;
00336   
00337   if ( sc.isFailure() )
00338     {
00339       return Error("Could not finaliaze base class GaudiTool", sc);
00340     }
00341   return StatusCode::SUCCESS;
00342 };

EqSolver& EqSolver::operator= ( const EqSolver  )  [private]

assignement operator is


Friends And Related Function Documentation

friend class ToolFactory< EqSolver > [friend]

Definition at line 33 of file EqSolver.h.


Member Data Documentation

std::string EqSolver::m_algType [private]

Definition at line 102 of file EqSolver.h.

double EqSolver::m_max_iter [private]

Definition at line 103 of file EqSolver.h.

double EqSolver::m_norm_residual [private]

Definition at line 104 of file EqSolver.h.

const gsl_multiroot_fdfsolver_type* EqSolver::m_type [private]

AlgTool type (concrete class name).

Reimplemented from AlgTool.

Definition at line 105 of file EqSolver.h.


The documentation for this class was generated from the following files:

Generated at Thu Jan 8 17:50:56 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004