20 const int cFlowType = 50;
21 const int cConnectorType = 100;
22 const int cSurfType = 102;
23 const int cInletType = 104;
24 const int cSymmType = 105;
25 const int cOutletType = 106;
26 const int cEmptyType = 107;
27 const int cOutletResType = 108;
28 const int cPorousType = 109;
47 doublereal time = 0.0) :
59 m_refiner(0), m_bw(-1) {
79 return (m_type >= cConnectorType);
127 virtual void setInitialState(doublereal* xlocal = 0) {}
128 virtual void setState(
size_t point,
const doublereal* state, doublereal* x) {}
135 virtual void resize(
size_t nv,
size_t np) {
138 if (nv != m_nv || !m_refiner) {
141 m_refiner =
new Refiner(*
this);
144 m_td.resize(m_nv, 1);
145 m_name.resize(m_nv,
"");
146 m_max.resize(m_nv, 0.0);
147 m_min.resize(m_nv, 0.0);
148 m_rtol_ss.resize(m_nv, 1.0e-8);
149 m_atol_ss.resize(m_nv, 1.0e-15);
150 m_rtol_ts.resize(m_nv, 1.0e-8);
151 m_atol_ts.resize(m_nv, 1.0e-15);
154 m_slast.resize(m_nv * m_points, 0.0);
172 throw IndexError(
"checkComponentIndex",
"points", n, m_nv-1);
194 throw IndexError(
"checkPointIndex",
"points", n, m_points-1);
209 if (m_name[n] !=
"") {
212 return "component " +
int2str(n);
216 void setComponentName(
size_t n,
const std::string& name) {
220 void setComponentType(
size_t n,
int ctype) {
229 for (
size_t n = 0; n < nc; n++) {
235 "no component named "+name);
241 size_t nu,
const doublereal* upper) {
243 if (nl < m_nv || nu < m_nv)
245 "wrong array size for solution bounds. "
246 "Size should be at least "+
int2str(m_nv));
247 std::copy(upper, upper + m_nv, m_max.begin());
248 std::copy(lower, lower + m_nv, m_min.begin());
251 void setBounds(
size_t n, doublereal lower, doublereal upper) {
259 size_t na,
const doublereal*
atol,
int ts = 0);
298 return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]);
303 return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]);
321 std::copy(x0 +
loc(), x0 +
loc() + size(), m_slast.begin());
335 return (m_rdt == 0.0);
340 return (m_rdt != 0.0);
355 void evalss(doublereal* x, doublereal* r, integer* mask) {
370 virtual void eval(
size_t j, doublereal* x, doublereal* r,
371 integer* mask, doublereal rdt=0.0);
373 virtual doublereal residual(doublereal* x,
size_t n,
size_t j) {
374 throw CanteraError(
"Domain1D::residual",
"residual function must be overloaded in derived class "+
id());
377 int timeDerivativeFlag(
size_t n) {
380 void setAlgebraic(
size_t n) {
384 virtual void update(doublereal* x) {}
386 doublereal time()
const {
389 void incrementTime(doublereal dt) {
392 size_t index(
size_t n,
size_t j)
const {
395 doublereal value(
const doublereal* x,
size_t n,
size_t j)
const {
396 return x[index(n,j)];
399 virtual void setJac(MultiJac* jac) {}
413 virtual XML_Node&
save(XML_Node& o,
const doublereal*
const sol);
426 virtual void restore(
const XML_Node& dom, doublereal* soln,
int loglevel);
428 size_t size()
const {
429 return m_nv*m_points;
461 virtual size_t loc(
size_t j = 0)
const {
478 return m_jstart + m_points - 1;
513 return m_slast[m_nv*j + n];
521 std::string id()
const {
525 return std::string(
"domain ") +
int2str(m_index);
533 const std::string& desc() {
537 virtual void getTransientMask(integer* mask) {}
539 virtual void showSolution_s(std::ostream& s,
const doublereal* x) {}
544 doublereal z(
size_t jlocal)
const {
547 doublereal zmin()
const {
550 doublereal zmax()
const {
551 return m_z[m_points - 1];
554 void setProfile(
const std::string& name, doublereal* values, doublereal* soln) {
555 for (
size_t n = 0; n < m_nv; n++) {
557 for (
size_t j = 0; j < m_points; j++) {
558 soln[index(n, j) +
m_iloc] = values[j];
563 throw CanteraError(
"Domain1D::setProfile",
564 "unknown component: "+name);
573 doublereal grid(
size_t point) {
578 virtual void setupGrid(
size_t n,
const doublereal* z);
580 void setGrid(
size_t n,
const doublereal* z);
643 std::vector<std::string> m_name;
Container class for multiple-domain 1D problems.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
virtual void _getInitialSoln(doublereal *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
size_t componentIndex(const std::string &name) const
index of component with name name.
size_t nPoints() const
Number of grid points in this domain.
Domain1D * left() const
Return a pointer to the left neighbor.
void locate()
Find the index of the first grid point in this domain, and the start of its variables in the global s...
void checkPointIndex(size_t n) const
Check that the specified point index is in range Throws an exception if n is greater than nPoints()-1...
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain...
const size_t npos
index returned by functions to indicate "no position"
size_t firstPoint() const
The index of the first (i.e., left-most) grid point belonging to this domain.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
void setTolerancesSS(doublereal rtol, doublereal atol, size_t n=npos)
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
void setContainer(OneDim *c, size_t index)
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
void linkLeft(Domain1D *left)
Set the left neighbor to domain 'left.
std::vector< int > vector_int
Vector of ints.
void checkComponentIndex(size_t n) const
Check that the specified component index is in range Throws an exception if n is greater than nCompon...
void setBounds(size_t nl, const doublereal *lower, size_t nu, const doublereal *upper)
Set the lower and upper bounds for each solution component.
void setBandwidth(int bw=-1)
Set the Jacobian bandwidth. See the discussion of method bandwidth().
size_t nComponents() const
Number of components at each grid point.
Base class for one-dimensional domains.
std::string m_id
Identity tag for the domain.
void setTolerances(size_t nr, const doublereal *rtol, size_t na, const doublereal *atol, int ts=0)
set the error tolerances for all solution components.
size_t bandwidth()
Set the Jacobian bandwidth for this domain.
size_t lastPoint() const
The index of the last (i.e., right-most) grid point belonging to this domain.
void setID(const std::string &s)
Specify an identifying tag for this domain.
doublereal lowerBound(size_t n) const
Lower bound on the nth component.
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate...
Classes providing support for XML data files.
virtual void showSolution(const doublereal *x)
Print the solution.
Base class for exceptions thrown by Cantera classes.
Domain1D * right() const
Return a pointer to the right neighbor.
virtual void resize(size_t nv, size_t np)
void setDesc(const std::string &s)
Specify descriptive text for this domain.
Refiner & refiner()
Return a reference to the grid refiner.
doublereal upperBound(size_t n) const
Upper bound on the nth component.
void evalss(doublereal *x, doublereal *r, integer *mask)
void checkPointArraySize(size_t nn) const
Check that an array size is at least nPoints() Throws an exception if nn is less than nPoints()...
int domainType()
Domain type flag.
size_t domainIndex()
The left-to-right location of this domain.
Domain1D(size_t nv=1, size_t points=1, doublereal time=0.0)
Constructor.
void setSteadyTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for steady-state mode.
virtual void eval(size_t j, doublereal *x, doublereal *r, integer *mask, doublereal rdt=0.0)
Evaluate the residual function at point j.
void append(Domain1D *right)
Append domain 'right' to this one, and update all links.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
bool steady()
True if in steady-state mode.
void setTolerancesTS(doublereal rtol, doublereal atol, size_t n=npos)
Contains declarations for string manipulation functions within Cantera.
void linkRight(Domain1D *right)
Set the right neighbor to domain 'right.'.
void checkComponentArraySize(size_t nn) const
Check that an array size is at least nComponents() Throws an exception if nn is less than nComponents...
doublereal atol(size_t n)
Absolute tolerance of the nth component.
const OneDim & container() const
The container holding this domain.
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
doublereal rtol(size_t n)
Relative tolerance of the nth component.
An array index is out of range.
bool isConnector()
True if the domain is a connector domain.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
void setTransientTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for time-stepping mode.
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
virtual doublereal initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
void initTimeInteg(doublereal dt, const doublereal *x0)