OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
FuelCell::ApplicationCore::NewtonLineSearch Class Reference

Application class performing a Newton's iteration as described in newtonBase. More...

#include <newton_w_line_search.h>

Inheritance diagram for FuelCell::ApplicationCore::NewtonLineSearch:
Inheritance graph
[legend]
Collaboration diagram for FuelCell::ApplicationCore::NewtonLineSearch:
Collaboration graph
[legend]

Public Member Functions

 NewtonLineSearch (ApplicationBase &app)
 Constructor, receiving the application computing the residual and solving the linear problem. More...
 
virtual void declare_parameters (ParameterHandler &param)
 Declare the input parameters. More...
 
void _initialize (ParameterHandler &param)
 Read the parameters local to NewtonLineSearch. More...
 
virtual void initialize (ParameterHandler &param)
 Read the parameters. More...
 
virtual void solve (FuelCell::ApplicationCore::FEVector &u, const FuelCell::ApplicationCore::FEVectors &in_vectors)
 The actual Newton solver. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::newtonBase
 newtonBase (ApplicationBase &app)
 Constructor, receiving the application computing the residual and solving the linear problem. More...
 
void _initialize (ParameterHandler &param)
 Read the parameters local to newtonBase. More...
 
double threshold (double new_value)
 Set the maximal residual reduction allowed without triggering assembling in the next step. More...
 
void initialize_initial_guess (BlockVector< double > &dst)
 Control object for the Newton iteration. More...
 
virtual void assemble ()
 Instead of assembling, this function only sets a flag, such that the inner application will be required to assemble a new derivative matrix next time solve() is called. More...
 
virtual double residual (FuelCell::ApplicationCore::FEVector &dst, const FuelCell::ApplicationCore::FEVectors &rhs)
 Returns the L2-norm of the residual and the residual vector in "dst" using the residual function in the ApplicationBase used to initialize the application. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::ApplicationWrapper
 ApplicationWrapper (ApplicationBase &app)
 Constructor for a derived application. More...
 
 ~ApplicationWrapper ()
 Destructor. More...
 
virtual void remesh ()
 Generate the next mesh depending on the mesh generation parameters. More...
 
virtual void init_vector (FEVector &dst) const
 Initialize vector to problem size. More...
 
virtual double residual (FEVector &dst, const FEVectors &src, bool apply_boundaries=true)
 Compute residual of src and store it into dst. More...
 
virtual void Tsolve (FEVector &dst, const FEVectors &src)
 Solve the dual system assembled with right hand side rhs and return the result in start. More...
 
virtual double estimate (const FEVectors &src)
 Estimate cell-wise errors. More...
 
virtual double evaluate (const FEVectors &src)
 Evaluate a functional. More...
 
virtual void grid_out (const std::string &filename) const
 
virtual void data_out (const std::string &filename, const FEVectors &src)
 Write data in the format specified by the ParameterHandler. More...
 
virtual std::string id () const
 Return a unique identification string for this application. More...
 
virtual void notify (const Event &reason)
 Add a reason for assembling. More...
 
- Public Member Functions inherited from FuelCell::ApplicationCore::ApplicationBase
 ApplicationBase (boost::shared_ptr< ApplicationData > data=boost::shared_ptr< ApplicationData >())
 Constructor for an application. More...
 
 ApplicationBase (const ApplicationBase &other)
 Copy constructor. More...
 
virtual ~ApplicationBase ()
 Virtual destructor. More...
 
void print_parameters_to_file (ParameterHandler &param, const std::string &file_name, const ParameterHandler::OutputStyle &style)
 Print default parameters for the application to a file. More...
 
virtual void start_vector (FEVector &dst, std::string) const
 Initialize vector to problem size. More...
 
virtual void grid_out (const std::string &)
 Write the mesh in the format specified by the ParameterHandler. More...
 
boost::shared_ptr
< ApplicationData
get_data ()
 Get access to the protected variable data. More...
 
const boost::shared_ptr
< ApplicationData
get_data () const
 Get read-only access to the protected variable data. More...
 
virtual void clear ()
 All true in notifications. More...
 
virtual void clear_events ()
 All false in notifications. More...
 
virtual unsigned int get_solution_index ()
 Returns solution index. More...
 

Static Public Attributes

static const
FuelCell::ApplicationCore::Event 
bad_derivative
 The Event set by NewtonLineSearch if convergence is becoming bad and a new matrix should be assembled. More...
 
- Static Public Attributes inherited from FuelCell::ApplicationCore::newtonBase
static const
FuelCell::ApplicationCore::Event 
bad_derivative
 The Event set if convergence is becoming bad and a new matrix should be assembled. More...
 

Private Member Functions

bool find_negative_values (const FEVector &u)
 Routine used to find if there are any negative values on a given solution block. More...
 

Private Attributes

double overrelax
 Value used to multiply $\delta u$, the solution update, from the Newton algorithm during the first overrelax_steps iterations. More...
 
unsigned int overrelax_steps
 Number of iterations to which we apply overrelax. More...
 
bool line_search
 Do you want to use a line search at each step? More...
 
unsigned int block_to_fix
 Block not allowed to be negative: More...
 

Additional Inherited Members

- Public Attributes inherited from FuelCell::ApplicationCore::newtonBase
ReductionControl control
 Control object for the Newton iteration. More...
 
double numIter
 Number of Iterations;. More...
 
- Protected Member Functions inherited from FuelCell::ApplicationCore::newtonBase
void debug_output (const FEVector &sol, const FEVector &update, const FEVector &residual) const
 Function used to output any necessary information at each Newton iteration for debugging purposes. More...
 
- Protected Member Functions inherited from FuelCell::ApplicationCore::ApplicationWrapper
SmartPointer< ApplicationBaseget_wrapped_application ()
 Gain access to the inner application. More...
 
- Protected Member Functions inherited from FuelCell::ApplicationCore::ApplicationBase
void print_caller_name (const std::string &caller_name) const
 Print caller name. More...
 
- Protected Attributes inherited from FuelCell::ApplicationCore::newtonBase
bool assemble_now
 This flag is set by the function assemble(), indicating that the matrix must be assembled anew upon start. More...
 
double assemble_threshold
 Threshold for re-assembling matrix. More...
 
bool debug_solution
 Print updated solution after each step into file Newton_uNNN? More...
 
bool debug_update
 Print Newton update after each step into file Newton_dNNN? More...
 
bool debug_residual
 Print Newton residual after each step into file Newton_rNNN? More...
 
unsigned int debug
 Write debug output to FcstUtilities::log; the higher the number, the more output. More...
 
unsigned int step
 The number of a basic Newton iteration. More...
 
std::vector< unsigned int > blocks
 This vector specifies the blocks of the global solution which are supposed to be treated specially. More...
 
unsigned int n_blocks
 The total number of blocks. More...
 
- Protected Attributes inherited from FuelCell::ApplicationCore::ApplicationWrapper
SmartPointer< ApplicationBaseapp
 Pointer to the application this one depends upon. More...
 
- Protected Attributes inherited from FuelCell::ApplicationCore::ApplicationBase
boost::shared_ptr
< ApplicationData
data
 Object for auxiliary data. More...
 
Event notifications
 Accumulate reasons for assembling here. More...
 

Detailed Description

Application class performing a Newton's iteration as described in newtonBase.

The implemented algorithm attempts to find a step size length, $ h $, such that the scalar function

\[ f (h) = \| \mathbf{F}(\mathbf{x}_{i−1} + h \delta \mathbf{x} ) \|_2^2. \]

is reduced at every step. The meaning of $ \delta \mathbf{x} $ and how it is obtained is described in the documentation for the base class, i.e. newtonBase.

The method used to determine $ h $ is referred to as the global-convergence strategy. The strategy can greatly affect both the efficiency and versatility of Newton’s method.

This class contains two methods to determine $ h $ . Two options are possible.

Overrelaxation and step size control

If, in the Newton subsection in the parameter file, the option "Line search" is set to false, i.e. set Line search = false, then a normal Netwon iteration is performed where $ h = 1 $. However, since Newton methods are notorious for overshooting the solution at the initial stages, the algorithm allows the user to specify an overrelaxation constant, $ h $, for a given number of steps, i.e. overrelax_steps, such that the step size during the initial stages of the algorithm, i.e. for iteration number < overrelax_steps, $ h $ is given as follows:

\[ h = overrelaxation*step \]

where step is the iteration number in the Newton solver. The overrelaxation constant is specified in the Newton subsection in the input file with set Initial Overrelaxation = 0.2. The parameter overrelax_steps is set in the same section with set Number of iterations with overrelaxation = 1.

In addition to the overrelaxation option, the algorithm makes sure that after every iteration the residual is reduced. If the residual is not reduced, then the step size, $ h = 1 $, is discarded and updated with

\[ h = 2^{-i} \]

where $ i $ is the number of failed attempts.

Line search

If, in the Newton subsection in the parameter file, the option "Line search" is set to true, i.e. set Line search = true, then a line search is performed at every iteration in order to estimate the value of $ h $.

In this case, the line search simply involves evaluating the residual at several points, by default 5 points, with $ h_i = 2^{-i} $ and $ i = 1,...,5 $.

At each iteration a line search is performed by evaluating the L2 norm of the residual for each $ h_i $ and then the best step size is selected.

Parameters

The parameters that control all Newton solvers are defined in the subsection Newton in the data input file. The parameters are the following:

* subsection Newton
* //NewtonLineSearch specific parameters
* set Line search = false # Specify if the code should perform a line search
* set Initial Overrelaxation = 1 # Specify the over-relaxation length, \alpha, for the initial step, i.e. u_i = u_{i-1} + \alpha \delta u
* set Number of iterations with overrelaxation = 1 # Specify for how many steps should the code overrelax the update ()
* // All the parameters below are from NetwonBase:
* set Max steps = 100 # Maximum number of iterations
* set Tolerance = 1.e-8 # Absolute tolerance
* set Reduction = 1.e-20 # Maximum allowed reduction during line search. If the residual is not reduced by at least this number the iteration is discarded.
* set Assemble threshold = 0.0 # Used as a threshold to state if the Jacobian needs to be re-evaluated
* set Debug level = 0
* set Debug residual = false # Would you like the code to output the residual at every Newton iteration?
* set Debug solution = false # Would you like the code to output the solution at every Newton iteration?
* set Debug update = false
* end
*
Author
Marc Secanell, 2007

Constructor & Destructor Documentation

FuelCell::ApplicationCore::NewtonLineSearch::NewtonLineSearch ( ApplicationBase app)

Constructor, receiving the application computing the residual and solving the linear problem.

Member Function Documentation

void FuelCell::ApplicationCore::NewtonLineSearch::_initialize ( ParameterHandler &  param)

Read the parameters local to NewtonLineSearch.

virtual void FuelCell::ApplicationCore::NewtonLineSearch::declare_parameters ( ParameterHandler &  param)
virtual

Declare the input parameters.

Reimplemented from FuelCell::ApplicationCore::newtonBase.

bool FuelCell::ApplicationCore::NewtonLineSearch::find_negative_values ( const FEVector u)
private

Routine used to find if there are any negative values on a given solution block.

The block searched is given in

  • Solution variable not allowed to be negative

If you do not want to search any block, provide a negative value.

virtual void FuelCell::ApplicationCore::NewtonLineSearch::initialize ( ParameterHandler &  param)
virtual

Read the parameters.

Reimplemented from FuelCell::ApplicationCore::newtonBase.

virtual void FuelCell::ApplicationCore::NewtonLineSearch::solve ( FuelCell::ApplicationCore::FEVector u,
const FuelCell::ApplicationCore::FEVectors in_vectors 
)
virtual

The actual Newton solver.

Implements FuelCell::ApplicationCore::newtonBase.

Member Data Documentation

const FuelCell::ApplicationCore::Event FuelCell::ApplicationCore::NewtonLineSearch::bad_derivative
static

The Event set by NewtonLineSearch if convergence is becoming bad and a new matrix should be assembled.

unsigned int FuelCell::ApplicationCore::NewtonLineSearch::block_to_fix
private

Block not allowed to be negative:

bool FuelCell::ApplicationCore::NewtonLineSearch::line_search
private

Do you want to use a line search at each step?

double FuelCell::ApplicationCore::NewtonLineSearch::overrelax
private

Value used to multiply $\delta u$, the solution update, from the Newton algorithm during the first overrelax_steps iterations.

We will multiply the first iteration by $\alpha \delta u$, where $ \alpha $ is the value of overrelax and then the following iterations by $it \alpha \delta u$ where $ it $ is the iteration number

unsigned int FuelCell::ApplicationCore::NewtonLineSearch::overrelax_steps
private

Number of iterations to which we apply overrelax.


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