31 OneDim(span<
const shared_ptr<Domain1D>> domains);
56 double weightedNorm(span<const double> step)
const override;
74 if (n >=
m_dom.size()) {
75 throw IndexError(
"OneDim::checkDomainIndex",
"domains", n,
m_dom.size());
83 if (
m_dom.size() > nn) {
91 if (
m_dom[i]->nComponents()) {
92 return m_dom[i]->loc();
102 return m_dom[0].get();
107 return m_dom.back().get();
122 std::tuple<string, size_t, string>
component(
size_t i)
const;
142 void initTimeInteg(
double dt, span<const double> x)
override;
156 void eval(
size_t j, span<const double> x, span<double> r,
157 double rdt=-1.0,
int count=1);
159 void eval(span<const double> x, span<double> r,
160 double rdt=-1.0,
int count=1)
override
190 "To be removed after Cantera 4.0. Use solverStats() instead.");
192 auto& v =
m_stats[
"grid_points"].asVector<
long int>();
193 return vector<size_t>(v.begin(), v.end());
200 "To be removed after Cantera 4.0. Use solverStats() instead.");
202 return m_stats[
"jacobian_time"].asVector<
double>();
210 "To be removed after Cantera 4.0. Use solverStats() instead.");
212 return m_stats[
"residual_time"].asVector<
double>();
219 "To be removed after Cantera 4.0. Use solverStats() instead.");
221 auto& v =
m_stats[
"jacobian_evals"].asVector<
long int>();
222 return vector<int>(v.begin(), v.end());
230 "To be removed after Cantera 4.0. Use solverStats() instead.");
232 auto& v =
m_stats[
"residual_evals"].asVector<
long int>();
233 return vector<int>(v.begin(), v.end());
240 "To be removed after Cantera 4.0. Use solverStats() instead.");
242 auto& v =
m_stats[
"steps"].asVector<
long int>();
243 return vector<int>(v.begin(), v.end());
Declarations for class SystemJacobian.
Base class for one-dimensional domains.
An array index is out of range.
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(span< 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.
size_t gridSize() const override
Value reported as grid_points in solver statistics.
pair< string, string > componentTableHeader() const override
Get header lines describing the column names included in a component label.
void initTimeInteg(double dt, span< const double > x) override
Prepare for time stepping beginning with solution x and timestep dt.
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.
vector< int > jacobianCountStats()
Return number of Jacobian evaluations made in each call to solve()
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.
Domain1D * right()
Pointer to right-most domain (last added).
size_t domainIndex(const string &name) const
Get the index of the domain named name.
vector< double > evalTimeStats()
Return wall-clock time spent on non-Jacobian function evaluations in each call to solve()
const vector< double > & _workVector() const
Access internal work array.
vector< double > jacobianTimeStats()
Return wall-clock time spent evaluating Jacobians in each call to solve()
OneDim()=default
Default constructor.
void setSteadyMode() override
Prepare to solve the steady-state problem.
vector< shared_ptr< Domain1D > > m_connect
All connector and boundary domains.
vector< size_t > gridSizeStats()
Return total grid size 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.
vector< shared_ptr< Domain1D > > m_bulk
All bulk/flow domains.
vector< size_t > m_loc
Location in the state vector of the first component of each point, across all domains.
size_t nVars(size_t jg)
Number of solution components at global point jg.
void evalJacobian(span< const double > x0) override
Evaluates the Jacobian at x0 using finite differences.
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...
Domain1D * pointDomain(size_t i)
Return a pointer to the domain global point i belongs to.
size_t points()
Total number of points.
vector< size_t > m_nvars
Number of variables at each point, across all domains.
vector< int > timeStepStats()
Return number of time steps taken in each call to solve()
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.
size_t m_pts
Total number of points.
void resetBadValues(span< double > x) override
Reset values such as negative species concentrations.
Domain1D & domain(size_t i) const
Return a reference to domain i.
vector< shared_ptr< Domain1D > > m_dom
All domains comprising the system.
Domain1D * left()
Pointer to left-most domain (first added).
void eval(span< const double > x, span< double > r, double rdt=-1.0, int count=1) override
Evaluate the residual function.
double lowerBound(size_t i) const override
Get the lower bound for global component i in the state vector.
vector< int > evalCountStats()
Return number of non-Jacobian function evaluations made in each call to solve()
void eval(size_t j, span< const double > x, span< double > r, double rdt=-1.0, int count=1)
Evaluate the multi-domain residual function.
Base class for representing a system of differential-algebraic equations and solving for its steady-s...
vector< double > m_xnew
Work array used to hold the residual or the new solution.
virtual void saveStats()
Commit statistics for the current grid into m_stats and reset the staging counters.
double rdt() const
Reciprocal of the time step.
AnyMap m_stats
Committed per-grid statistics.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
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.