33 OneDim(vector<shared_ptr<Domain1D>>& domains);
41 "To be removed after Cantera 3.2. Use linearSolver() instead.");
88 if (n >=
m_dom.size()) {
89 throw IndexError(
"OneDim::checkDomainIndex",
"domains", n,
m_dom.size());
97 if (
m_dom.size() > nn) {
105 if (
m_dom[i]->nComponents()) {
106 return m_dom[i]->loc();
116 return m_dom[0].get();
121 return m_dom.back().get();
136 std::tuple<string, size_t, string>
component(
size_t i)
const;
170 void eval(
size_t j,
double* x,
double* r,
double rdt=-1.0,
int count=1);
172 void eval(
double* x,
double* r,
double rdt=-1.0,
int count=1)
override {
Declarations for class SystemJacobian.
Base class for one-dimensional domains.
An array index is out of range.
Class MultiJac evaluates the Jacobian of a system of equations defined by a residual function supplie...
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.
void init()
Initialize all domains.
void checkDomainIndex(size_t n) const
Check that the specified domain index is in range.
double weightedNorm(const double *step) const override
Compute the weighted norm of a step vector.
void resize() override
Call to set the size of internal data structures after first defining the system or if the problem si...
string componentName(size_t i) const override
Get the name of the i-th component of the state vector.
void saveStats()
Save statistics on function and Jacobian evaluation, and reset the counters.
pair< string, string > componentTableHeader() const override
Get header lines describing the column names included in a component label.
size_t loc(size_t jg)
Location in the solution vector of the first component of global point jg.
double upperBound(size_t i) const override
Get the upper bound for global component i in the state vector.
void eval(size_t j, double *x, double *r, double rdt=-1.0, int count=1)
Evaluate the multi-domain residual function.
void addDomain(shared_ptr< Domain1D > d)
Add a domain. Domains are added left-to-right.
string componentTableLabel(size_t i) const override
Get elements of the component name, aligned with the column headings given by componentTableHeader().
size_t nDomains() const
Number of domains.
vector< double > m_jacElapsed
Time [s] spent evaluating Jacobians on this grid.
Domain1D * right()
Pointer to right-most domain (last added).
OneDim()=default
Default constructor.
void setSteadyMode() override
Prepare to solve the steady-state problem.
vector< double > m_funcElapsed
Time [s] spent on residual function evaluations on this grid (not counting evaluations used to constr...
const vector< int > & evalCountStats()
Return number of non-Jacobian function evaluations made in each call to solve()
vector< shared_ptr< Domain1D > > m_connect
All connector and boundary domains.
const vector< int > & jacobianCountStats()
Return number of Jacobian evaluations made in each call to solve()
void checkDomainArraySize(size_t nn) const
Check that an array size is at least nDomains().
vector< std::tuple< size_t, size_t, size_t > > m_componentInfo
Domain, grid point, and component indices for each element of the global state vector.
const vector< size_t > & gridSizeStats()
Return total grid size in each call to solve()
const vector< int > & timeStepStats()
Return number of time steps taken in each call to solve()
vector< shared_ptr< Domain1D > > m_bulk
All bulk/flow domains.
vector< int > m_funcEvals
Number of residual function evaluations on this grid (not counting evaluations used to construct Jaco...
vector< size_t > m_loc
Location in the state vector of the first component of each point, across all domains.
void evalJacobian(double *x0) override
Evaluates the Jacobian at x0 using finite differences.
double m_evaltime
Total time [s] spent in eval()
size_t nVars(size_t jg)
Number of solution components at global point jg.
std::tuple< string, size_t, string > component(size_t i) const
Return the domain, local point index, and component name for the i-th component of the global solutio...
size_t domainIndex(const string &name)
Get the index of the domain named name.
Domain1D * pointDomain(size_t i)
Return a pointer to the domain global point i belongs to.
void resetBadValues(double *x) override
Reset values such as negative species concentrations.
vector< size_t > m_gridpts
Number of grid points in this grid.
size_t points()
Total number of points.
vector< size_t > m_nvars
Number of variables at each point, across all domains.
int m_nevals
Number of calls to eval()
bool m_init
Indicates whether one-time initialization for each domain has been completed.
void writeStats(int printTime=1)
Write statistics about the number of iterations and Jacobians at each grid level.
void clearStats()
Clear saved statistics.
void eval(double *x, double *r, double rdt=-1.0, int count=1) override
Evaluate the residual function.
size_t m_pts
Total number of points.
vector< int > m_jacEvals
Number of Jacobian evaluations on this grid.
const vector< double > & jacobianTimeStats()
Return CPU time spent evaluating Jacobians in each call to solve()
void initTimeInteg(double dt, double *x) override
Prepare for time stepping beginning with solution x and timestep dt.
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.
vector< shared_ptr< Domain1D > > m_dom
All domains comprising the system.
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).
double lowerBound(size_t i) const override
Get the lower bound for global component i in the state vector.
shared_ptr< SystemJacobian > getJacobian()
Base class for representing a system of differential-algebraic equations and solving for its steady-s...
double rdt() const
Reciprocal of the time step.
shared_ptr< SystemJacobian > m_jac
Jacobian evaluator.
MultiJac & jacobian()
Return a reference to the Jacobian evaluator of an OneDim object.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.