19 : m_tmin(1.0e-16), m_tmax(10.0), m_tfactor(0.5),
21 m_rdt(0.0), m_jac_ok(false),
22 m_nd(0), m_bw(0), m_size(0),
24 m_ss_jac_age(10), m_ts_jac_age(20),
25 m_nevals(0), m_evaltime(0.0)
38 m_tmin(1.0e-16), m_tmax(10.0), m_tfactor(0.5),
40 m_rdt(0.0), m_jac_ok(false),
41 m_nd(0), m_bw(0), m_size(0),
43 m_ss_jac_age(10), m_ts_jac_age(20),
44 m_nevals(0), m_evaltime(0.0)
50 int nd =
static_cast<int>(domains.size());
52 for (i = 0; i < nd; i++) {
60 size_t OneDim::domainIndex(
string name)
62 for (
size_t n = 0; n <
m_nd; n++) {
63 if (
domain(n).
id() == name) {
67 throw CanteraError(
"OneDim::domainIndex",
"no domain named >>"+name+
"<<");
80 int n =
static_cast<int>(m_dom.size());
82 m_dom.back()->append(d);
87 m_connect.push_back(d);
121 sprintf(buf,
"\nStatistics:\n\n Grid Functions Time Jacobians Time \n");
123 size_t n = m_gridpts.size();
124 for (
size_t i = 0; i < n; i++) {
126 sprintf(buf,
"%5s %5i %9.4f %5i %9.4f \n",
127 int2str(m_gridpts[i]).c_str(), m_funcEvals[i], m_funcElapsed[i],
128 m_jacEvals[i], m_jacElapsed[i]);
130 sprintf(buf,
"%5s %5i NA %5i NA \n",
131 int2str(m_gridpts[i]).c_str(), m_funcEvals[i], m_jacEvals[i]);
153 int nev = m_jac->
nEvals();
154 if (nev > 0 && m_nevals > 0) {
155 m_gridpts.push_back(m_pts);
156 m_jacEvals.push_back(m_jac->
nEvals());
158 m_funcEvals.push_back(m_nevals);
160 m_funcElapsed.push_back(m_evaltime);
173 std::vector<size_t> nvars,
loc;
179 for (
size_t i = 0; i <
m_nd; i++) {
184 for (
size_t n = 0; n < np; n++) {
203 bw2 = m_dom[i-1]->bandwidth();
205 bw2 = m_dom[i-1]->nComponents();
216 m_size = d->
loc() + d->size();
222 m_mask.resize(
size());
229 for (
size_t i = 0; i <
m_nd; i++) {
230 m_dom[i]->setJac(m_jac);
239 m_jac->
eval(x, xnew, 0.0);
240 m_jac->updateTransient(m_rdt,
DATA_PTR(m_mask));
243 int m = m_newt->
solve(x, xnew, *
this, *m_jac, loglevel);
247 void OneDim::evalSSJacobian(doublereal* x, doublereal* xnew)
249 doublereal rdt_save = m_rdt;
253 m_jac->
eval(x, xnew, 0.0);
283 void OneDim::eval(
size_t j,
double* x,
double* r, doublereal rdt,
int count)
285 clock_t t0 = clock();
286 fill(r, r + m_size, 0.0);
287 fill(m_mask.begin(), m_mask.end(), 0);
292 vector<Domain1D*>::iterator d;
295 for (d = m_bulk.begin(); d != m_bulk.end(); ++d) {
296 (*d)->eval(j, x, r,
DATA_PTR(m_mask), rdt);
300 for (d = m_connect.begin(); d != m_connect.end(); ++d) {
301 (*d)->eval(j, x, r,
DATA_PTR(m_mask), rdt);
306 clock_t t1 = clock();
307 m_evaltime += double(t1 - t0)/CLOCKS_PER_SEC;
321 for (
size_t i = 0; i < m_size; i++) {
333 doublereal rdt_old = m_rdt;
338 if (fabs(rdt_old - m_rdt) >
Tiny) {
339 m_jac->updateTransient(m_rdt,
DATA_PTR(m_mask));
360 m_jac->updateTransient(m_rdt,
DATA_PTR(m_mask));
408 doublereal* r,
int loglevel)
416 writelog(
"\n\n step size (s) log10(ss) \n");
417 writelog(
"===============================\n");
426 sprintf(str,
" %4d %10.4g %10.4g" , n,dt,log10(ss));
434 m =
solve(x, r, loglevel-1);
443 copy(r, r + m_size, x);
462 "Time integration failed.");
476 void OneDim::save(
string fname,
string id,
string desc, doublereal* sol)
482 newtime = localtime(&aclock);
485 ifstream fin(fname.c_str());
492 while (same_ID != 0) {
493 idnew =
id +
"_" +
int2str(jid);
495 same_ID = root.
findID(idnew);
499 ct = &root.
child(
"ctml");
501 ct = &root.addChild(
"ctml");
503 XML_Node& sim = (XML_Node&)ct->addChild(
"simulation");
505 addString(sim,
"timestamp",asctime(newtime));
510 Domain1D* d =
left();
515 ofstream s(fname.c_str());
517 throw CanteraError(
"save",
"could not open file "+fname);
521 writelog(
"Solution saved to file "+fname+
" as solution "+
id+
".\n");
525 void Domain1D::setGrid(
size_t n,
const doublereal* z)
529 for (
size_t j = 0; j < m_points; j++) {