32 OneDim(vector<shared_ptr<Domain1D>>& domains);
36 OneDim(vector<Domain1D*> domains);
61 int solve(
double* x0,
double* x1,
int loglevel);
73 size_t domainIndex(
const string& name);
78 if (n >=
m_dom.size()) {
79 throw IndexError(
"OneDim::checkDomainIndex",
"domains", n,
88 if (
m_dom.size() > nn) {
96 if (
m_dom[i]->nComponents()) {
97 return m_dom[i]->loc();
133 std::tuple<string, size_t, string>
component(
size_t i);
157 double ssnorm(
double* x,
double* r);
169 return (
m_rdt != 0.0);
174 return (
m_rdt == 0.0);
196 void eval(
size_t j,
double* x,
double* r,
double rdt=-1.0,
int count = 1);
208 vector<int>& transientMask() {
222 double timeStep(
int nsteps,
double dt,
double* x,
double* r,
int loglevel);
224 void resetBadValues(
double* x);
236 AnyMap
serialize(
const double* soln)
const;
239 void setMinTimeStep(
double tmin) {
242 void setMaxTimeStep(
double tmax) {
245 void setTimeStepFactor(
double tfactor) {
261 void setJacAge(
int ss_age,
int ts_age=-1);
296 return m_funcElapsed;
334 void evalSSJacobian(
double* x,
double* xnew);
352 vector<shared_ptr<Domain1D>> m_sharedDom;
353 vector<shared_ptr<Domain1D>> m_sharedConnect;
354 vector<shared_ptr<Domain1D>> m_sharedBulk;
361 vector<size_t> m_nvars;
362 vector<size_t> m_loc;
367 int m_ss_jac_age = 20;
368 int m_ts_jac_age = 20;
385 double m_evaltime = 0;
386 vector<size_t> m_gridpts;
387 vector<int> m_jacEvals;
388 vector<double> m_jacElapsed;
389 vector<int> m_funcEvals;
390 vector<double> m_funcElapsed;
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.
int solve(double *x0, double *x1, int loglevel)
Solve F(x) = 0, where F(x) is the multi-domain residual function.
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 init()
Initialize all domains.
vector< Domain1D * > m_bulk
void checkDomainIndex(size_t n) const
Check that the specified domain index is in range.
size_t m_size
solution vector size
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, for example after being refined.
AnyMap serialize(const double *soln) const
void saveStats()
Save statistics on function and Jacobian evaluation, and reset the counters.
unique_ptr< MultiNewton > m_newt
Newton iterator.
size_t size() const
Total solution vector length;.
size_t loc(size_t jg)
Location in the solution vector of the first component of global point jg.
void eval(size_t j, double *x, double *r, double rdt=-1.0, int count=1)
Evaluate the multi-domain residual function.
double ssnorm(double *x, double *r)
Steady-state max norm (infinity norm) of the residual evaluated using solution x.
void addDomain(shared_ptr< Domain1D > d)
Add a domain. Domains are added left-to-right.
double rdt() const
Reciprocal of the time step.
void initTimeInteg(double dt, double *x)
Prepare for time stepping beginning with solution x and timestep dt.
size_t nDomains() const
Number of domains.
Domain1D * right()
Pointer to right-most domain (last added).
std::tuple< string, size_t, string > component(size_t i)
Return the domain, local point index, and component name for the i-th component of the global solutio...
size_t bandwidth() const
Jacobian bandwidth.
double m_rdt
reciprocal of time step
shared_ptr< vector< double > > m_state
Solution vector.
const vector< int > & evalCountStats()
Return number of non-Jacobian function evaluations made 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.
const vector< int > & jacobianCountStats()
Return number of Jacobian evaluations made in each call to solve()
vector< Domain1D * > m_connect
bool transient() const
True if transient mode.
void checkDomainArraySize(size_t nn) const
Check that an array size is at least nDomains().
const vector< size_t > & gridSizeStats()
Return total grid size in each call to solve()
void setMaxTimeStepCount(int nmax)
Set the maximum number of timeteps allowed before successful steady-state solve.
const vector< int > & timeStepStats()
Return number of time steps taken in each call to solve()
unique_ptr< MultiJac > m_jac
Jacobian evaluator.
size_t nVars(size_t jg)
Number of solution components at global point jg.
size_t m_bw
Jacobian bandwidth.
double m_tfactor
factor time step is multiplied by if time stepping fails ( < 1 )
vector< Domain1D * > m_dom
bool m_jac_ok
if true, Jacobian is current
int maxTimeStepCount() const
Return the maximum number of timeteps allowed before successful steady-state solve.
double timeStep(int nsteps, double dt, double *x, double *r, int loglevel)
Take time steps using Backward Euler.
Domain1D * pointDomain(size_t i)
Return a pointer to the domain global point i belongs to.
double m_tmin
minimum timestep size
size_t points()
Total number of points.
double m_tmax
maximum timestep size
void writeStats(int printTime=1)
Write statistics about the number of iterations and Jacobians at each grid level.
void clearStats()
Clear saved statistics.
void setSteadyMode()
Prepare to solve the steady-state problem.
const vector< double > & 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.
vector< int > m_timeSteps
Number of time steps taken in each call to solve() (for example, for each successive grid refinement)
Domain1D & domain(size_t i) const
Return a reference to domain i.
const vector< double > & evalTimeStats()
Return CPU time spent on non-Jacobian function evaluations in each call to solve()
Domain1D * left()
Pointer to left-most domain (first added).
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.
MultiJac & jacobian()
Return a reference to the Jacobian evaluator of an OneDim object.
Namespace for the Cantera kernel.