31 OneDim(std::vector<Domain1D*> domains);
51 int solve(doublereal* x0, doublereal* x1,
int loglevel);
63 size_t domainIndex(
const std::string& name);
68 if (n >= m_dom.size()) {
69 throw IndexError(
"OneDim::checkDomainIndex",
"domains", n,
78 if (m_dom.size() > nn) {
86 if (m_dom[i]->nComponents()) {
87 return m_dom[i]->loc();
123 std::tuple<std::string, size_t, std::string>
component(
size_t i);
147 doublereal
ssnorm(doublereal* x, doublereal* r);
158 bool transient()
const {
159 return (
m_rdt != 0.0);
164 return (
m_rdt == 0.0);
186 void eval(
size_t j,
double* x,
double* r, doublereal
rdt=-1.0,
213 double timeStep(
int nsteps,
double dt,
double* x,
214 double* r,
int loglevel);
216 void resetBadValues(
double* x);
227 void save(
const std::string& fname, std::string
id,
228 const std::string& desc, doublereal* sol,
int loglevel);
231 void setMinTimeStep(doublereal tmin) {
234 void setMaxTimeStep(doublereal tmax) {
237 void setTimeStepFactor(doublereal tfactor) {
253 void setJacAge(
int ss_age,
int ts_age=-1);
288 return m_funcElapsed;
326 void evalSSJacobian(doublereal* x, doublereal* xnew);
342 std::vector<Domain1D*> m_dom, m_connect, m_bulk;
345 std::vector<size_t> m_nvars;
346 std::vector<size_t> m_loc;
349 doublereal m_solve_time;
352 int m_ss_jac_age, m_ts_jac_age;
369 doublereal m_evaltime;
370 std::vector<size_t> m_gridpts;
Base class for one-dimensional domains.
Base class for 'functor' classes that evaluate a function of one variable.
An array index is out of range.
Class MultiJac evaluates the Jacobian of a system of equations defined by a residual function supplie...
Newton iterator for multi-domain, one-dimensional problems.
Container class for multiple-domain 1D problems.
size_t start(size_t i) const
The index of the start of domain i in the solution vector.
int m_nsteps
Number of time steps taken in the current call to solve()
void checkDomainIndex(size_t n) const
Check that the specified domain index is in range.
vector_int m_timeSteps
Number of time steps taken in each call to solve() (e.g.
doublereal m_rdt
reciprocal of time step
size_t m_size
solution vector size
const vector_int & jacobianCountStats()
Return number of Jacobian evaluations made in each call to solve()
int m_nsteps_max
Maximum number of timesteps allowed per call to solve()
virtual void resize()
Call after one or more grids has changed size, e.g. after being refined.
std::unique_ptr< MultiJac > m_jac
Jacobian evaluator.
void saveStats()
Save statistics on function and Jacobian evaluation, and reset the counters.
size_t size() const
Total solution vector length;.
doublereal ssnorm(doublereal *x, doublereal *r)
Steady-state max norm (infinity norm) of the residual evaluated using solution x.
const vector_int & evalCountStats()
Return number of non-Jacobian function evaluations made in each call to solve()
size_t loc(size_t jg)
Location in the solution vector of the first component of global point jg.
Domain1D * left()
Pointer to left-most domain (first added).
size_t nDomains() const
Number of domains.
std::tuple< std::string, size_t, std::string > component(size_t i)
Return the domain, local point index, and component name for the i-th component of the global solutio...
const vector_int & timeStepStats()
Return number of time steps taken in each call to solve()
Domain1D * right()
Pointer to right-most domain (last added).
doublereal m_tmin
minimum timestep size
size_t bandwidth() const
Jacobian bandwidth.
double timeStep(int nsteps, double dt, double *x, double *r, int loglevel)
void eval(size_t j, double *x, double *r, doublereal rdt=-1.0, int count=1)
Evaluate the multi-domain residual function.
const vector_fp & evalTimeStats()
Return CPU time spent on non-Jacobian function evaluations in each call to solve()
void setTimeStepCallback(Func1 *callback)
Set a function that will be called after each successful timestep.
Func1 * m_interrupt
Function called at the start of every call to eval.
void checkDomainArraySize(size_t nn) const
Check that an array size is at least nDomains().
void setMaxTimeStepCount(int nmax)
Set the maximum number of timeteps allowed before successful steady-state solve.
void initTimeInteg(doublereal dt, doublereal *x)
Prepare for time stepping beginning with solution x and timestep dt.
size_t nVars(size_t jg)
Number of solution components at global point jg.
std::unique_ptr< MultiNewton > m_newt
Newton iterator.
size_t m_bw
Jacobian bandwidth.
bool m_jac_ok
if true, Jacobian is current
const std::vector< size_t > & gridSizeStats()
Return total grid size in each call to solve()
int maxTimeStepCount() const
Return the maximum number of timeteps allowed before successful steady-state solve.
Domain1D * pointDomain(size_t i)
Return a pointer to the domain global point i belongs to.
doublereal m_tmax
maximum timestep size
void addDomain(Domain1D *d)
Add a domain. Domains are added left-to-right.
size_t points()
Total number of points.
MultiJac & jacobian()
Return a reference to the Jacobian evaluator.
void writeStats(int printTime=1)
Write statistics about the number of iterations and Jacobians at each grid level.
void clearStats()
Clear saved statistics.
const vector_fp & jacobianTimeStats()
Return CPU time spent evaluating Jacobians in each call to solve()
Func1 * m_time_step_callback
User-supplied function called after each successful timestep.
doublereal m_tfactor
factor time step is multiplied by if time stepping fails ( < 1 )
int solve(doublereal *x0, doublereal *x1, int loglevel)
Solve F(x) = 0, where F(x) is the multi-domain residual function.
Domain1D & domain(size_t i) const
Return a reference to domain i.
bool steady() const
True if steady mode.
MultiNewton & newton()
Return a reference to the Newton iterator.
void setInterrupt(Func1 *interrupt)
Set a function that will be called every time eval is called.
doublereal rdt() const
Reciprocal of the time step.
std::vector< int > vector_int
Vector of ints.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.