Cantera  2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
MultiNewton Class Reference

Newton iterator for multi-domain, one-dimensional problems. More...

#include <MultiNewton.h>

Public Member Functions

 MultiNewton (int sz)
 
size_t size ()
 
void step (doublereal *x, doublereal *step, OneDim &r, MultiJac &jac, int loglevel)
 Compute undamped step.
 
doublereal boundStep (const doublereal *x0, const doublereal *step0, const OneDim &r, int loglevel)
 Compute factor to keep all components in bounds.
 
int dampStep (const doublereal *x0, const doublereal *step0, doublereal *x1, doublereal *step1, doublereal &s1, OneDim &r, MultiJac &jac, int loglevel, bool writetitle)
 On entry, step0 must contain an undamped Newton step for the solution x0.
 
doublereal norm2 (const doublereal *x, const doublereal *step, OneDim &r) const
 Compute the weighted 2-norm of 'step'.
 
int solve (doublereal *x0, doublereal *x1, OneDim &r, MultiJac &jac, int loglevel)
 Find the solution to F(X) = 0 by damped Newton iteration.
 
void setOptions (int maxJacAge=5)
 Set options.
 
void resize (size_t points)
 Change the problem size.
 

Protected Member Functions

doublereal * getWorkArray ()
 Get a pointer to an array of length m_n for temporary work space.
 
void releaseWorkArray (doublereal *work)
 Release a work array by pushing its pointer onto the stack of available arrays.
 

Protected Attributes

std::vector< doublereal * > m_workarrays
 
int m_maxAge
 
size_t m_nv
 
size_t m_np
 
size_t m_n
 
doublereal m_elapsed
 

Private Attributes

char m_buf [100]
 

Detailed Description

Newton iterator for multi-domain, one-dimensional problems.

Used by class OneDim.

Definition at line 21 of file MultiNewton.h.

Member Function Documentation

void step ( doublereal *  x,
doublereal *  step,
OneDim r,
MultiJac jac,
int  loglevel 
)

Compute undamped step.

Compute the undamped Newton step.

The residual function is evaluated at x, but the Jacobian is not recomputed.

Definition at line 107 of file MultiNewton.cpp.

References Domain1D::componentName(), OneDim::domain(), OneDim::eval(), Cantera::int2str(), Domain1D::loc(), Domain1D::nComponents(), OneDim::nDomains(), Cantera::npos, OneDim::pointDomain(), OneDim::size(), BandMatrix::solve(), and OneDim::start().

Referenced by MultiNewton::dampStep(), and MultiNewton::solve().

doublereal boundStep ( const doublereal *  x0,
const doublereal *  step0,
const OneDim r,
int  loglevel 
)

Compute factor to keep all components in bounds.

Return the factor by which the undamped Newton step 'step0' must be multiplied in order to keep all solution components in all domains between their specified lower and upper bounds.

Definition at line 173 of file MultiNewton.cpp.

References Cantera::bound_step(), OneDim::domain(), ckr::min(), OneDim::nDomains(), and OneDim::start().

Referenced by MultiNewton::dampStep().

int dampStep ( const doublereal *  x0,
const doublereal *  step0,
doublereal *  x1,
doublereal *  step1,
doublereal &  s1,
OneDim r,
MultiJac jac,
int  loglevel,
bool  writetitle 
)

On entry, step0 must contain an undamped Newton step for the solution x0.

This method attempts to find a damping coefficient such that the next undamped step would have a norm smaller than that of step0. If successful, the new solution after taking the damped step is returned in x1, and the undamped step at x1 is returned in step1.

Definition at line 194 of file MultiNewton.cpp.

References MultiJac::age(), MultiNewton::boundStep(), Cantera::DampFactor, Cantera::int2str(), Cantera::NDAMP, MultiJac::nEvals(), MultiNewton::norm2(), Cantera::SmallNumber, OneDim::ssnorm(), MultiNewton::step(), and Cantera::writelog().

Referenced by MultiNewton::solve().

doublereal norm2 ( const doublereal *  x,
const doublereal *  step,
OneDim r 
) const

Compute the weighted 2-norm of 'step'.

Definition at line 88 of file MultiNewton.cpp.

References OneDim::domain(), OneDim::nDomains(), Cantera::norm_square(), OneDim::size(), and OneDim::start().

Referenced by MultiNewton::dampStep().

int solve ( doublereal *  x0,
doublereal *  x1,
OneDim r,
MultiJac jac,
int  loglevel 
)

Find the solution to F(X) = 0 by damped Newton iteration.

On entry, x0 contains an initial estimate of the solution. On successful return, x1 contains the converged solution.

Definition at line 298 of file MultiNewton.cpp.

References MultiJac::age(), MultiNewton::dampStep(), DATA_PTR, MultiJac::eval(), OneDim::eval(), MultiNewton::getWorkArray(), MultiJac::incrementAge(), Cantera::int2str(), MultiJac::nEvals(), Cantera::npos, OneDim::rdt(), MultiNewton::releaseWorkArray(), OneDim::ssnorm(), MultiNewton::step(), and Cantera::writelog().

Referenced by OneDim::solve().

void setOptions ( int  maxJacAge = 5)
inline

Set options.

Definition at line 52 of file MultiNewton.h.

Referenced by OneDim::timeStep().

void resize ( size_t  points)

Change the problem size.

Prepare for a new solution vector length.

Definition at line 75 of file MultiNewton.cpp.

Referenced by OneDim::resize().

doublereal * getWorkArray ( )
protected

Get a pointer to an array of length m_n for temporary work space.

Definition at line 406 of file MultiNewton.cpp.

Referenced by MultiNewton::solve().

void releaseWorkArray ( doublereal *  work)
protected

Release a work array by pushing its pointer onto the stack of available arrays.

Definition at line 423 of file MultiNewton.cpp.

Referenced by MultiNewton::solve().


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