16 void Domain1D::setTransientTolerances(doublereal rtol, doublereal atol,
size_t n)
19 for (n = 0; n < m_nv; n++) {
29 void Domain1D::setSteadyTolerances(doublereal rtol, doublereal atol,
size_t n)
32 for (n = 0; n < m_nv; n++) {
42 void Domain1D::needJacUpdate()
45 m_container->jacobian().setAge(10000);
46 m_container->saveStats();
50 void Domain1D::eval(
size_t jg, doublereal* xg, doublereal* rg,
51 integer* mask, doublereal rdt)
54 if (jg !=
npos && (jg + 1 < firstPoint() || jg > lastPoint() + 1)) {
64 doublereal* x = xg + loc();
65 doublereal* rsd = rg + loc();
66 integer* diag = mask + loc();
68 size_t jmin, jmax, jpt, j, i;
69 jpt = jg - firstPoint();
75 jmin = std::max<size_t>(jpt, 1) - 1;
76 jmax = std::min(jpt+1,m_points-1);
79 for (j = jmin; j <= jmax; j++) {
80 if (j == 0 || j == m_points - 1) {
81 for (i = 0; i < m_nv; i++) {
82 rsd[index(i,j)] = residual(x,i,j);
86 for (i = 0; i < m_nv; i++) {
87 rsd[index(i,j)] = residual(x,i,j)
88 - timeDerivativeFlag(i)*rdt*(value(x,i,j) - prevSoln(i,j));
89 diag[index(i,j)] = timeDerivativeFlag(i);
101 addFloatArray(d,
"abstol_transient", nComponents(), &m_atol_ts[0]);
102 addFloatArray(d,
"reltol_transient", nComponents(), &m_rtol_ts[0]);
103 addFloatArray(d,
"abstol_steady", nComponents(), &m_atol_ss[0]);
104 addFloatArray(d,
"reltol_steady", nComponents(), &m_rtol_ss[0]);
108 void Domain1D::restore(
const XML_Node& dom, doublereal* soln,
int loglevel)
111 vector<XML_Node*> nodes = dom.
getChildren(
"floatArray");
112 for (
size_t i = 0; i < nodes.size(); i++) {
113 string title = nodes[i]->attrib(
"title");
115 if (values.size() != nComponents()) {
117 writelog(
"Warning: Domain1D::restore: Got an array of length " +
118 int2str(values.size()) +
" when one of length " +
119 int2str(nComponents()) +
" was expected. " +
120 "Tolerances for individual species may not be preserved.\n");
126 if (!values.empty()) {
127 values.resize(nComponents(), values[values.size()-1]);
134 if (title ==
"abstol_transient") {
136 }
else if (title ==
"reltol_transient") {
138 }
else if (title ==
"abstol_steady") {
140 }
else if (title ==
"reltol_steady") {
144 "Got an unexpected array, '" + title +
"'");
149 void Domain1D::setupGrid(
size_t n,
const doublereal* z)
153 for (
size_t j = 0; j < m_points; j++) {
159 void Domain1D::showSolution(
const doublereal* x)
165 for (i = 0; i < nn; i++) {
166 writeline(
'-', 79,
false,
true);
167 sprintf(buf,
"\n z ");
169 for (n = 0; n < 5; n++) {
170 sprintf(buf,
" %10s ",componentName(i*5 + n).c_str());
173 writeline(
'-', 79,
false,
true);
174 for (j = 0; j < m_points; j++) {
175 sprintf(buf,
"\n %10.4g ",m_z[j]);
177 for (n = 0; n < 5; n++) {
178 v = value(x, i*5+n, j);
179 sprintf(buf,
" %10.4g ",v);
185 size_t nrem = m_nv - 5*nn;
186 writeline(
'-', 79,
false,
true);
187 sprintf(buf,
"\n z ");
189 for (n = 0; n < nrem; n++) {
190 sprintf(buf,
" %10s ", componentName(nn*5 + n).c_str());
193 writeline(
'-', 79,
false,
true);
194 for (j = 0; j < m_points; j++) {
195 sprintf(buf,
"\n %10.4g ",m_z[j]);
197 for (n = 0; n < nrem; n++) {
198 v = value(x, nn*5+n, j);
199 sprintf(buf,
" %10.4g ", v);
206 void Domain1D::_getInitialSoln(doublereal* x)
208 for (
size_t j = 0; j < m_points; j++) {
209 for (
size_t n = 0; n < m_nv; n++) {
210 x[index(n,j)] = initialValue(n,j);
215 doublereal Domain1D::initialValue(
size_t n,
size_t j)
218 "base class method called!");
void addFloatArray(XML_Node &node, const std::string &title, const size_t n, const doublereal *const vals, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "floatArray", with a value consisting of a comma separ...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
const size_t npos
index returned by functions to indicate "no position"
Class XML_Node is a tree-based representation of the contents of an XML file.
Base class for exceptions thrown by Cantera classes.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
size_t getFloatArray(const XML_Node &node, std::vector< doublereal > &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
void writelog(const std::string &msg)
Write a message to the screen.
void getChildren(const std::string &name, std::vector< XML_Node * > &children) const
Get a vector of pointers to XML_Node containing all of the children of the current node which matches...