19 const int cFlowType = 50;
20 const int cConnectorType = 100;
21 const int cSurfType = 102;
22 const int cInletType = 104;
23 const int cSymmType = 105;
24 const int cOutletType = 106;
25 const int cEmptyType = 107;
26 const int cOutletResType = 108;
27 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);
238 void setBounds(
size_t n, doublereal lower, doublereal upper) {
265 return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]);
270 return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]);
288 std::copy(x0 +
loc(), x0 +
loc() + size(), m_slast.begin());
302 return (m_rdt == 0.0);
307 return (m_rdt != 0.0);
321 void evalss(doublereal* x, doublereal* r, integer* mask) {
336 virtual void eval(
size_t j, doublereal* x, doublereal* r,
337 integer* mask, doublereal rdt=0.0);
339 virtual doublereal residual(doublereal* x,
size_t n,
size_t j) {
340 throw CanteraError(
"Domain1D::residual",
"residual function must be overloaded in derived class "+
id());
343 int timeDerivativeFlag(
size_t n) {
346 void setAlgebraic(
size_t n) {
350 virtual void update(doublereal* x) {}
352 doublereal time()
const {
355 void incrementTime(doublereal dt) {
358 size_t index(
size_t n,
size_t j)
const {
361 doublereal value(
const doublereal* x,
size_t n,
size_t j)
const {
362 return x[index(n,j)];
365 virtual void setJac(MultiJac* jac) {}
379 virtual XML_Node&
save(XML_Node& o,
const doublereal*
const sol);
392 virtual void restore(
const XML_Node& dom, doublereal* soln,
int loglevel);
394 size_t size()
const {
395 return m_nv*m_points;
427 virtual size_t loc(
size_t j = 0)
const {
444 return m_jstart + m_points - 1;
479 return m_slast[m_nv*j + n];
487 std::string id()
const {
491 return std::string(
"domain ") +
int2str(m_index);
499 const std::string& desc() {
503 virtual void getTransientMask(integer* mask) {}
505 virtual void showSolution_s(std::ostream& s,
const doublereal* x) {}
510 doublereal z(
size_t jlocal)
const {
513 doublereal zmin()
const {
516 doublereal zmax()
const {
517 return m_z[m_points - 1];
520 void setProfile(
const std::string& name, doublereal* values, doublereal* soln) {
521 for (
size_t n = 0; n < m_nv; n++) {
523 for (
size_t j = 0; j < m_points; j++) {
524 soln[index(n, j) +
m_iloc] = values[j];
529 throw CanteraError(
"Domain1D::setProfile",
530 "unknown component: "+name);
539 doublereal grid(
size_t point) {
544 virtual void setupGrid(
size_t n,
const doublereal* z);
602 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 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 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.
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...
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.
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)