Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

NonLinEqSolver Class Reference

base class for solvers for systems of nonlinear equations. More...

#include <NonLinEqSolver.h>

Inheritance diagram for NonLinEqSolver::

HandleId ConjGradNonLin LinNonLin NewtonRaphson NonLinML SuccessiveSubst List of all members.

Public Methods

 NonLinEqSolver (const NonLinEqSolver_prm &pm)
virtual ~NonLinEqSolver ()
bool ok () const
void attachUserCode (NonLinEqSolverUDC &user_code)
void attachNonLinSol (LinEqVector &nonlinear_solution)
void attachNonLinSol (Vector(NUMT) &nonlinear_solution)
void attachLinSol (LinEqVector &linear_subproblem_solution)
void attachLinSol (Vector(NUMT) &linear_subproblem_solution)
void attachResidual (LinEqVector &residual)
void attachResidual (Vector(NUMT) &residual)
void attachMatrix (LinEqMatrix &coeff_matrix)
void attachMatrix (Matrix(NUMT) &coeff_matrix)
const NonLinEqSolverStategetCurrentState () const
virtual bool solve ()
virtual bool continuationSolve ()
virtual bool ordinarySolve ()=0
virtual void initSingleStep ()
virtual bool singleStep ()
void plotEps (CurvePlotFile &file)
void plotResidualNorm (CurvePlotFile &file)
void writeResults (StringList &results)
void writeExtendedResults (MultipleReporter &rep, VerbosityLevel level, CurvePlotFile &cplotfile)
CLASS_INFO DEF_VIRTUAL_CAST (NewtonRaphson) DEF_VIRTUAL_CAST(SuccessiveSubst) DEF_VIRTUAL_CAST(ConjGradNonLin) DEF_VIRTUAL_CAST(NonLinML) NonLinEqSolver()
void attachCommAdm (const SubdCommAdm &adm_)

Static Public Methods

void writeHeadings (StringList &headings)

Public Attributes

Handle(NonLinEqSolver_prmparams

Protected Methods

bool redim (const NonLinEqSolver_prm &pm)
void rememberConvData ()
void fillCurrentState (NonLinEqMethod scheme)
void startIterations ()
virtual bool converged ()
bool success ()
void getResidualNorm ()
bool gotResidualNorm ()

Protected Attributes

NonLinEqSolverUDCudc
Handle(LinEqVectornonlinear_sol
Handle(LinEqVectorlinear_subproblem_sol
Handle(LinEqVectorresidual
Handle(LinEqMatrixcoeff_matrix
NonLinEqSolverState current_state
real eps
int nincreases
int niterations
real rnorm
VecSimple(real) eps_development
VecSimple(real) rnorm_development
int nouter_iter
real lambda
Handle(SubdCommAdmcomm_adm

Detailed Description

base class for solvers for systems of nonlinear equations.

NAME: NonLinEqSolver - base class for solvers for systems of nonlinear equations

DESCRIPTION:

The "NonLinEqSolver" hierarchy is a collection of C++ classes for solving systems of nonlinear algebraic equations. In accordance with the Diffpack coding standard, the user dependent code is provided by a base class reference of type "NonLinEqSolverUDC". Various nonlinear solution algorithms are implemented as sublcasses of "NonLinEqSolver", and various parameters needed to initialize the "NonLinEqSolver" hierarchy are collected in a parameter class "NonLinEqSolver_prm". The user''s problem must be coded in terms of a class which is derived from class "NonLinEqSolverUDC".

The base class contains the basic convergence information such as the number of iterations and the estimated ""error"". These parameters are collected in a special "struct" (see class "NonLinEqSolverState") which is returned by the the "getCurrentState" function.

Derived classes, implementing various iterative methods, are responsible for defining appropriate ""error"" estimates. An attribute of class "NonLinEqSolver_prm", the "stopping_criterion" parameter, can be used to indicate different stopping criteria. The virtual function "converged" is responsible for defining and checking convergence criteria.

The virtual function "solve" carries out the steps in the iterative method. Sometimes a user want to change the stopping criterion data and these items are therefore defined as "public" in this base class.


Constructor & Destructor Documentation

NonLinEqSolver::NonLinEqSolver ( const NonLinEqSolver_prm & pm )
 

The constructor takes a "NonLinEqSolver_prm" object as argument and performs the necessary initialization. The "solve" function will in derived classes automatically redimension internal vectors etc.

NonLinEqSolver::~NonLinEqSolver ( ) [virtual]
 


Member Function Documentation

CLASS_INFO NonLinEqSolver::DEF_VIRTUAL_CAST ( NewtonRaphson )
 

void NonLinEqSolver::attachCommAdm ( const SubdCommAdm & adm_ )
 

void NonLinEqSolver::attachLinSol ( Vector(NUMT) & linear_subproblem_solution )
 

void NonLinEqSolver::attachLinSol ( LinEqVector & linear_subproblem_solution )
 

void NonLinEqSolver::attachMatrix ( Matrix(NUMT) & coeff_matrix )
 

void NonLinEqSolver::attachMatrix ( LinEqMatrix & coeff_matrix )
 

void NonLinEqSolver::attachNonLinSol ( Vector(NUMT) & nonlinear_solution )
 

void NonLinEqSolver::attachNonLinSol ( LinEqVector & nonlinear_solution )
 

void NonLinEqSolver::attachResidual ( Vector(NUMT) & residual )
 

void NonLinEqSolver::attachResidual ( LinEqVector & residual )
 

void NonLinEqSolver::attachUserCode ( NonLinEqSolverUDC & user_code )
 

bool NonLinEqSolver::continuationSolve ( ) [virtual]
 

implements a loop over a continuation parameter "lambda" that can be set on the "NonLinEqSolver_prm" menu (that is, a set of "lambda" values are given on the menu and the "continuationSolve" function runs a loop through this set). Typically, "lambda"=0 is an easy problem, and "lambda"=1 is the problem that one wants to solve. Convergence problems are serious for "lambda"=1, but not for "lambda"=0. The idea is then to obtain good startvalues for nonlinear solvers by using the startvector from the solution for the previous "lambda" value when solving for the next. Usually "lambda" reflects a physical parameter that influences the degree of nonlinearity significantly. Everywhere in the problem class, the programmer can read "NonLinEqSolver getCurrentState().continuation_prm" to see the current "lambda" value. Prior to each internal "solve" call in the "continutationSolve" function, the user''s problem class is given the control in a function "beforeSolveInContinuationMethod". In this function one can read the current "lambda" value (either as the argument or through a "getCurrentState" call) and scale physical parameters such that they correspond to the "lambda" parameter before "solve" starts to solve the nonlinear problem. For example, in a fluid flow problem governed by the Navier-Stokes equations, the Reynolds number may correspond to "lambda". If "Re" is the desired Reynolds number, and "Re_c" is the current Reynolds number used in the computations (i.e., the coefficient in the "integrands" routine), "beforeStartInContinutationMethod" could simply set "Re_c = lambda*Re". The "continuationSolve" is simply a loop over the "lambda" values where one in each iteration calls solve. If divergence occurs, one tries to achieve convergence with a smaller "lambda" value. Hence, more "lambda" values than those given on the menu can appear in the simulation.

bool NonLinEqSolver::converged ( ) [protected, virtual]
 

this is a protected function for use in the iteration loop. The function determines whether the iteration is to be terminated or not. See the man page for class "NonLinEqSolver_prm" for the available convergence criteria.

void NonLinEqSolver::fillCurrentState ( NonLinEqMethod scheme ) [protected]
 

const NonLinEqSolverState & NonLinEqSolver::getCurrentState ( ) const [inline]
 

returns a "struct" with several parameters reflecting the state of the solver, that is, the number of iterations, or current iteration number, the name ("enum") of the solution method, the estimated ""error"" etc.

void NonLinEqSolver::getResidualNorm ( ) [protected]
 

if the user has supplied the function "normOfResidual" in his "NonLinEqSolverUDC" derived class, "getResidualNorm" calls the user function, determines if it is really implemented (otherwise the "DUMMY" constant is returned) and stores the norm in the local variable "rnorm". This is the norm of residual of the nonlinear equations. The norm is needed for various convergence estimation as well as in various solution algorithms. Read the warning about implementation of "normOfResidual" in class "NonLinEqSolverUDC". (For use in derived classes only).

bool NonLinEqSolver::gotResidualNorm ( ) [protected]
 

returns "true" if the norm of the residual is provided (see description of "getResidualNorm"), otherwise the return value is "false". (For use in derived classes only).

void NonLinEqSolver::initSingleStep ( ) [virtual]
 

bool NonLinEqSolver::ok ( ) const
 

Reimplemented in NonLinML.

bool NonLinEqSolver::ordinarySolve ( ) [pure virtual]
 

Reimplemented in ConjGradNonLin, LinNonLin, NewtonRaphson, SuccessiveSubst, and NonLinML.

void NonLinEqSolver::plotEps ( CurvePlotFile & file )
 

generates a plot of the convergence history.

void NonLinEqSolver::plotResidualNorm ( CurvePlotFile & file )
 

generates a plot of the residual in some norm.

bool NonLinEqSolver::redim ( const NonLinEqSolver_prm & pm ) [protected]
 

void NonLinEqSolver::rememberConvData ( ) [protected]
 

bool NonLinEqSolver::singleStep ( ) [virtual]
 

this function is like "ordinarySolve", but a return is performed after each step in the iteration. Hence the user can check the development of the nonlinear iterations. This may be useful is convergence problems occur. The function returns "true" as long as the convergence criteria are not satisified, and "false" when the stopping criteria are satisfied. Note this difference in comparison with "solve". The user must implement the loop, usually in terms of a "while(performSingleStep)" type of construction. Prior to the loop, a call to "initSingleSteps" must be performed.

Reimplemented in ConjGradNonLin, LinNonLin, NewtonRaphson, SuccessiveSubst, and NonLinML.

bool NonLinEqSolver::solve ( ) [virtual]
 

solves the nonlinear system. A "true" return value indicates that the iteration scheme converged such that the most recent solution (stored in "nonlinear_sol") satisfied the convergence criteria. If the return value is "false", the convergence criteria were not satisfied. The "solve" function calls "ordinarySolve" (which depends on the method, e.g., Successive Substitution or Newton-Raphson) if not a set of continuation parameter values is given on the menu. In that case, "solve" calls "continuationSolve" (which sets up a loop and calls "ordinarySolve" according to the continuation algorithm).

void NonLinEqSolver::startIterations ( ) [protected]
 

Reimplemented in NonLinML.

bool NonLinEqSolver::success ( ) [protected]
 

returns a "bool" value of whether the iteration was successful or not. (For use in derived classes only).

void NonLinEqSolver::writeExtendedResults ( MultipleReporter & rep,
VerbosityLevel level,
CurvePlotFile & cplotfile )
 

void NonLinEqSolver::writeHeadings ( StringList & headings ) [static]
 

void NonLinEqSolver::writeResults ( StringList & results )
 


Member Data Documentation

Handle(LinEqMatrix) NonLinEqSolver::coeff_matrix [protected]
 

Handle(SubdCommAdm) NonLinEqSolver::comm_adm [protected]
 

NonLinEqSolverState NonLinEqSolver::current_state [protected]
 

real NonLinEqSolver::eps [protected]
 

VecSimple(real) NonLinEqSolver::eps_development [protected]
 

real NonLinEqSolver::lambda [protected]
 

Handle(LinEqVector) NonLinEqSolver::linear_subproblem_sol [protected]
 

int NonLinEqSolver::nincreases [protected]
 

int NonLinEqSolver::niterations [protected]
 

Handle(LinEqVector) NonLinEqSolver::nonlinear_sol [protected]
 

int NonLinEqSolver::nouter_iter [protected]
 

Handle(NonLinEqSolver_prm) NonLinEqSolver::params
 

Handle(LinEqVector) NonLinEqSolver::residual [protected]
 

real NonLinEqSolver::rnorm [protected]
 

VecSimple(real) NonLinEqSolver::rnorm_development [protected]
 

NonLinEqSolverUDC * NonLinEqSolver::udc [protected]
 


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.