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

Container class for multiple-domain 1D problems. More...

#include <OneDim.h>

Inheritance diagram for OneDim:
[legend]
Collaboration diagram for OneDim:
[legend]

Public Member Functions

 OneDim ()
 Default constructor.
 
 OneDim (std::vector< Domain1D * > domains)
 Construct a OneDim container for the domains pointed at by the input vector of pointers.
 
virtual ~OneDim ()
 Destructor.
 
void addDomain (Domain1D *d)
 Add a domain.
 
MultiJacjacobian ()
 Return a reference to the Jacobian evaluator.
 
MultiNewtonnewton ()
 Return a reference to the Newton iterator.
 
int solve (doublereal *x0, doublereal *x1, int loglevel)
 Solve F(x) = 0, where F(x) is the multi-domain residual function.
 
size_t nDomains () const
 Number of domains.
 
Domain1Ddomain (size_t i) const
 Return a reference to domain i.
 
size_t domainIndex (std::string name)
 
void checkDomainIndex (size_t n) const
 Check that the specified domain index is in range Throws an exception if n is greater than nDomains()-1.
 
void checkDomainArraySize (size_t nn) const
 Check that an array size is at least nDomains() Throws an exception if nn is less than nDomains().
 
size_t start (size_t i) const
 The index of the start of domain i in the solution vector.
 
size_t size () const
 Total solution vector length;.
 
Domain1Dleft ()
 Pointer to left-most domain (first added).
 
Domain1Dright ()
 Pointer to right-most domain (last added).
 
size_t nVars (size_t jg)
 Number of solution components at global point jg.
 
size_t loc (size_t jg)
 Location in the solution vector of the first component of global point jg.
 
size_t bandwidth () const
 Jacobian bandwidth.
 
void init ()
 Initialize.
 
size_t points ()
 Total number of points.
 
doublereal ssnorm (doublereal *x, doublereal *r)
 Steady-state max norm of the residual evaluated using solution x.
 
doublereal rdt () const
 Reciprocal of the time step.
 
void initTimeInteg (doublereal dt, doublereal *x)
 Prepare for time stepping beginning with solution x.
 
bool transient () const
 True if transient mode.
 
bool steady () const
 True if steady mode.
 
void setSteadyMode ()
 Set steady mode.
 
void eval (size_t j, double *x, double *r, doublereal rdt=-1.0, int count=1)
 Evaluate the multi-domain residual function.
 
Domain1DpointDomain (size_t i)
 Pointer to the domain global point i belongs to.
 
void resize ()
 Call after one or more grids has been refined.
 
vector_inttransientMask ()
 
double timeStep (int nsteps, double dt, double *x, double *r, int loglevel)
 Take time steps using Backward Euler.
 
void writeStats (int printTime=1)
 Write statistics about the number of iterations and Jacobians at each grid level.
 
void save (std::string fname, std::string id, std::string desc, doublereal *sol)
 
void setMinTimeStep (doublereal tmin)
 
void setMaxTimeStep (doublereal tmax)
 
void setTimeStepFactor (doublereal tfactor)
 
void setJacAge (int ss_age, int ts_age=-1)
 
void saveStats ()
 Save statistics on function and Jacobiab evaulation, and reset the counters.
 

Protected Member Functions

void evalSSJacobian (doublereal *x, doublereal *xnew)
 

Protected Attributes

doublereal m_tmin
 
doublereal m_tmax
 
doublereal m_tfactor
 
MultiJacm_jac
 
MultiNewtonm_newt
 
doublereal m_rdt
 
bool m_jac_ok
 
size_t m_nd
 number of domains
 
size_t m_bw
 
size_t m_size
 
std::vector< Domain1D * > m_dom
 
std::vector< Domain1D * > m_connect
 
std::vector< Domain1D * > m_bulk
 
bool m_init
 
std::vector< size_t > m_nvars
 
std::vector< size_t > m_loc
 
vector_int m_mask
 
size_t m_pts
 
doublereal m_solve_time
 
int m_ss_jac_age
 
int m_ts_jac_age
 

Private Attributes

int m_nevals
 
doublereal m_evaltime
 
std::vector< size_t > m_gridpts
 
vector_int m_jacEvals
 
vector_fp m_jacElapsed
 
vector_int m_funcEvals
 
vector_fp m_funcElapsed
 

Detailed Description

Container class for multiple-domain 1D problems.

Each domain is represented by an instance of Domain1D.

Definition at line 20 of file OneDim.h.

Constructor & Destructor Documentation

OneDim ( )

Default constructor.

Create an empty object.

Definition at line 18 of file OneDim.cpp.

OneDim ( std::vector< Domain1D * >  domains)

Construct a OneDim container for the domains pointed at by the input vector of pointers.

Definition at line 37 of file OneDim.cpp.

References OneDim::addDomain(), OneDim::init(), and OneDim::resize().

~OneDim ( )
virtual

Destructor.

Definition at line 101 of file OneDim.cpp.

Member Function Documentation

void addDomain ( Domain1D d)

Add a domain.

Domains are added left-to-right.

Definition at line 75 of file OneDim.cpp.

References OneDim::resize(), and Domain1D::setContainer().

Referenced by OneDim::OneDim().

MultiJac & jacobian ( )

Return a reference to the Jacobian evaluator.

Definition at line 107 of file OneDim.cpp.

Referenced by Domain1D::needJacUpdate().

MultiNewton & newton ( )

Return a reference to the Newton iterator.

Definition at line 111 of file OneDim.cpp.

Referenced by OneDim::timeStep().

int solve ( doublereal *  x0,
doublereal *  x1,
int  loglevel 
)

Solve F(x) = 0, where F(x) is the multi-domain residual function.

Parameters
x0Starting estimate of solution.
x1Final solution satisfying F(x1) = 0.
loglevelControls amount of diagnostic output.

Definition at line 235 of file OneDim.cpp.

References DATA_PTR, MultiJac::eval(), OneDim::eval(), Cantera::npos, and MultiNewton::solve().

Referenced by Sim1D::newtonSolve(), and OneDim::timeStep().

size_t nDomains ( ) const
inline

Number of domains.

Definition at line 52 of file OneDim.h.

References OneDim::m_nd.

Referenced by MultiNewton::boundStep(), MultiNewton::norm2(), and MultiNewton::step().

Domain1D& domain ( size_t  i) const
inline
void checkDomainIndex ( size_t  n) const
inline

Check that the specified domain index is in range Throws an exception if n is greater than nDomains()-1.

Definition at line 65 of file OneDim.h.

References OneDim::m_nd.

void checkDomainArraySize ( size_t  nn) const
inline

Check that an array size is at least nDomains() Throws an exception if nn is less than nDomains().

Used before calls which take an array pointer.

Definition at line 74 of file OneDim.h.

References OneDim::m_nd.

size_t start ( size_t  i) const
inline

The index of the start of domain i in the solution vector.

Definition at line 81 of file OneDim.h.

Referenced by MultiNewton::boundStep(), Sim1D::finalize(), MultiNewton::norm2(), Sim1D::refine(), Sim1D::showSolution(), Sim1D::Sim1D(), and MultiNewton::step().

size_t size ( ) const
inline

Total solution vector length;.

Definition at line 86 of file OneDim.h.

Referenced by MultiJac::MultiJac(), MultiNewton::norm2(), OneDim::resize(), Sim1D::Sim1D(), and MultiNewton::step().

Domain1D* left ( )
inline

Pointer to left-most domain (first added).

Definition at line 91 of file OneDim.h.

Referenced by OneDim::init(), OneDim::initTimeInteg(), and OneDim::setSteadyMode().

Domain1D* right ( )
inline

Pointer to right-most domain (last added).

Definition at line 96 of file OneDim.h.

Referenced by OneDim::pointDomain().

size_t nVars ( size_t  jg)
inline

Number of solution components at global point jg.

Definition at line 101 of file OneDim.h.

Referenced by MultiJac::eval().

size_t loc ( size_t  jg)
inline

Location in the solution vector of the first component of global point jg.

Definition at line 109 of file OneDim.h.

Referenced by MultiJac::eval(), OneDim::resize(), and Sim1D::restore().

size_t bandwidth ( ) const
inline

Jacobian bandwidth.

Definition at line 114 of file OneDim.h.

void init ( )

Initialize.

Initialize all domains.

On the first call, this methods calls the init method of each domain, proceeding from left to right. Subsequent calls do nothing.

Definition at line 375 of file OneDim.cpp.

References Domain1D::init(), OneDim::left(), and Domain1D::right().

Referenced by OneDim::OneDim().

size_t points ( )
inline

Total number of points.

Definition at line 122 of file OneDim.h.

Referenced by MultiJac::MultiJac().

doublereal ssnorm ( doublereal *  x,
doublereal *  r 
)

Steady-state max norm of the residual evaluated using solution x.

The 'infinity' (maximum magnitude) norm of the steady-state residual.

On return, array r contains the steady-state residual values.

Used only for diagnostic output.

Definition at line 317 of file OneDim.cpp.

References OneDim::eval(), ckr::max(), and Cantera::npos.

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

doublereal rdt ( ) const
inline

Reciprocal of the time step.

Definition at line 133 of file OneDim.h.

Referenced by MultiNewton::solve().

void initTimeInteg ( doublereal  dt,
doublereal *  x 
)

Prepare for time stepping beginning with solution x.

Prepare for time stepping with timestep dt.

Definition at line 331 of file OneDim.cpp.

References DATA_PTR, Domain1D::initTimeInteg(), OneDim::left(), Domain1D::right(), and Cantera::Tiny.

Referenced by OneDim::timeStep().

bool transient ( ) const
inline

True if transient mode.

Definition at line 141 of file OneDim.h.

bool steady ( ) const
inline

True if steady mode.

Definition at line 146 of file OneDim.h.

void setSteadyMode ( )

Set steady mode.

Prepare to solve the steady-state problem.

After invoking this method, subsequent calls to solve() will solve the steady-state problem.

Set the reciprocal of the time step to zero, and, if it was previously non-zero, signal that a new Jacobian will be needed.

Definition at line 357 of file OneDim.cpp.

References DATA_PTR, OneDim::left(), Domain1D::right(), and Domain1D::setSteadyMode().

Referenced by OneDim::timeStep().

void eval ( size_t  j,
double *  x,
double *  r,
doublereal  rdt = -1.0,
int  count = 1 
)

Evaluate the multi-domain residual function.

Evaluate the multi-domain residual function, and return the result in array r.

Parameters
jif j > 0, only evaluate residual for points j-1, j, and j + 1; otherwise, evaluate at all grid points.
xsolution vector
ron return, contains the residual vector
rdtReciprocal of the time step. if omitted, then the default value is used.
countSet to zero to omit this call from the statistics

Definition at line 283 of file OneDim.cpp.

References DATA_PTR.

Referenced by MultiJac::eval(), OneDim::solve(), MultiNewton::solve(), OneDim::ssnorm(), and MultiNewton::step().

Domain1D * pointDomain ( size_t  i)

Pointer to the domain global point i belongs to.

Return a pointer to the domain that contains component i of the global solution vector.

The domains are scanned right-to-left, and the first one with starting location less or equal to i is returned.

8/26/02 changed '<' to '<=' DGG

Definition at line 266 of file OneDim.cpp.

References Domain1D::left(), Domain1D::loc(), and OneDim::right().

Referenced by MultiNewton::step().

void resize ( )
doublereal timeStep ( int  nsteps,
double  dt,
double *  x,
double *  r,
int  loglevel 
)

Take time steps using Backward Euler.

nsteps – number of steps dt – initial step size loglevel – controls amount of printed diagnostics

Definition at line 407 of file OneDim.cpp.

References OneDim::initTimeInteg(), OneDim::newton(), MultiNewton::setOptions(), OneDim::setSteadyMode(), OneDim::solve(), OneDim::ssnorm(), and Cantera::writelog().

void writeStats ( int  printTime = 1)

Write statistics about the number of iterations and Jacobians at each grid level.

Parameters
printTimeBoolean that indicates whether time should be printed out The default is true. It's turned off for test problems where we don't want to print any times

Definition at line 117 of file OneDim.cpp.

References Cantera::int2str(), OneDim::saveStats(), and Cantera::writelog().

void saveStats ( )

Save statistics on function and Jacobiab evaulation, and reset the counters.

Statistics are saved only if the number of Jacobian evaluations is greater than zero. The statistics saved are

  • number of grid points
  • number of Jacobian evaluations
  • CPU time spent evaluating Jacobians
  • number of non-Jacobian function evaluations
  • CPU time spent evaluating functions

Definition at line 150 of file OneDim.cpp.

References MultiJac::elapsedTime(), and MultiJac::nEvals().

Referenced by Domain1D::needJacUpdate(), OneDim::resize(), and OneDim::writeStats().

Member Data Documentation

size_t m_nd
protected

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