Cantera  2.1.2
Sim1D.cpp
Go to the documentation of this file.
1 /**
2  * @file Sim1D.cpp
3  */
4 
5 #include "cantera/oneD/Sim1D.h"
7 
8 #include <fstream>
9 
10 using namespace std;
11 
12 namespace Cantera
13 {
14 
15 static void sim1D_drawline()
16 {
17  string s(78,'.');
18  s += '\n';
19  writelog(s.c_str());
20 }
21 
22 Sim1D::Sim1D() :
23  OneDim()
24 {
25  //writelog("Sim1D default constructor\n");
26 }
27 
28 Sim1D::Sim1D(vector<Domain1D*>& domains) :
29  OneDim(domains)
30 {
31  // resize the internal solution vector and the work array, and perform
32  // domain-specific initialization of the solution vector.
33 
34  m_x.resize(size(), 0.0);
35  m_xnew.resize(size(), 0.0);
36  for (size_t n = 0; n < m_nd; n++) {
38  domain(n).m_adiabatic=false;
39  }
40 
41  // set some defaults
42  m_tstep = 1.0e-5;
43  //m_maxtimestep = 10.0;
44  m_steps.push_back(1);
45  m_steps.push_back(2);
46  m_steps.push_back(5);
47  m_steps.push_back(10);
48 }
49 
50 void Sim1D::setInitialGuess(const std::string& component, vector_fp& locs, vector_fp& vals)
51 {
52  for (size_t dom=0; dom<m_nd; dom++) {
53  Domain1D& d = domain(dom);
54  size_t ncomp = d.nComponents();
55  for (size_t comp=0; comp<ncomp; comp++) {
56  if (d.componentName(comp)==component) {
57  setProfile(dom,comp,locs,vals);
58  }
59  }
60  }
61 }
62 
63 void Sim1D::setValue(size_t dom, size_t comp, size_t localPoint, doublereal value)
64 {
65  size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint);
66  AssertThrowMsg(iloc < m_x.size(), "Sim1D::setValue",
67  "Index out of bounds:" + int2str(iloc) + " > " +
68  int2str(m_x.size()));
69  m_x[iloc] = value;
70 }
71 
72 doublereal Sim1D::value(size_t dom, size_t comp, size_t localPoint) const
73 {
74  size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint);
75  AssertThrowMsg(iloc < m_x.size(), "Sim1D::value",
76  "Index out of bounds:" + int2str(iloc) + " > " +
77  int2str(m_x.size()));
78  return m_x[iloc];
79 }
80 
81 doublereal Sim1D::workValue(size_t dom, size_t comp, size_t localPoint) const
82 {
83  size_t iloc = domain(dom).loc() + domain(dom).index(comp, localPoint);
84  AssertThrowMsg(iloc < m_x.size(), "Sim1D::workValue",
85  "Index out of bounds:" + int2str(iloc) + " > " +
86  int2str(m_x.size()));
87  return m_xnew[iloc];
88 }
89 
90 void Sim1D::setProfile(size_t dom, size_t comp,
91  const vector_fp& pos, const vector_fp& values)
92 {
93 
94  Domain1D& d = domain(dom);
95  doublereal z0 = d.zmin();
96  doublereal z1 = d.zmax();
97  doublereal zpt, frac, v;
98  for (size_t n = 0; n < d.nPoints(); n++) {
99  zpt = d.z(n);
100  frac = (zpt - z0)/(z1 - z0);
101  v = linearInterp(frac, pos, values);
102  setValue(dom, comp, n, v);
103  }
104 }
105 
106 void Sim1D::save(const std::string& fname, const std::string& id,
107  const std::string& desc, int loglevel)
108 {
109  OneDim::save(fname, id, desc, DATA_PTR(m_x), loglevel);
110 }
111 
112 void Sim1D::saveResidual(const std::string& fname, const std::string& id,
113  const std::string& desc, int loglevel)
114 {
115  vector_fp res(m_x.size(), -999);
116  OneDim::eval(npos, &m_x[0], &res[0], 0.0);
117  OneDim::save(fname, id, desc, &res[0], loglevel);
118 }
119 
120 void Sim1D::restore(const std::string& fname, const std::string& id,
121  int loglevel)
122 {
123  ifstream s(fname.c_str());
124  if (!s)
125  throw CanteraError("Sim1D::restore",
126  "could not open input file "+fname);
127 
128  XML_Node root;
129  root.build(s);
130  s.close();
131 
132  XML_Node* f = root.findID(id);
133  if (!f) {
134  throw CanteraError("Sim1D::restore","No solution with id = "+id);
135  }
136 
137  vector<XML_Node*> xd;
138  f->getChildren("domain", xd);
139  if (xd.size() != m_nd) {
140  throw CanteraError("Sim1D::restore", "Solution does not contain the "
141  " correct number of domains. Found " +
142  int2str(xd.size()) + "expected " +
143  int2str(m_nd) + ".\n");
144  }
145  size_t sz = 0;
146  for (size_t m = 0; m < m_nd; m++) {
147  if (loglevel > 0 && xd[m]->attrib("id") != domain(m).id()) {
148  writelog("Warning: domain names do not match: '" +
149  (*xd[m])["id"] + + "' and '" + domain(m).id() + "'\n");
150  }
151  sz += domain(m).nComponents() * intValue((*xd[m])["points"]);
152  }
153  m_x.resize(sz);
154  m_xnew.resize(sz);
155  for (size_t m = 0; m < m_nd; m++) {
156  domain(m).restore(*xd[m], DATA_PTR(m_x) + domain(m).loc(), loglevel);
157  }
158  resize();
159  finalize();
160 }
161 
162 void Sim1D::setFlatProfile(size_t dom, size_t comp, doublereal v)
163 {
164  size_t np = domain(dom).nPoints();
165  size_t n;
166  for (n = 0; n < np; n++) {
167  setValue(dom, comp, n, v);
168  }
169 }
170 
171 void Sim1D::showSolution(ostream& s)
172 {
173  for (size_t n = 0; n < m_nd; n++) {
174  if (domain(n).domainType() != cEmptyType) {
175  domain(n).showSolution_s(s, DATA_PTR(m_x) + start(n));
176  }
177  }
178 }
179 
180 void Sim1D::showSolution()
181 {
182  for (size_t n = 0; n < m_nd; n++) {
183  if (domain(n).domainType() != cEmptyType) {
184  writelog("\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> "+domain(n).id()
185  +" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
187  }
188  }
189 }
190 
191 void Sim1D::getInitialSoln()
192 {
193  for (size_t n = 0; n < m_nd; n++) {
195  }
196 }
197 
199 {
200  for (size_t n = 0; n < m_nd; n++) {
201  domain(n)._finalize(DATA_PTR(m_x) + start(n));
202  }
203 }
204 
205 void Sim1D::setTimeStep(doublereal stepsize, size_t n, integer* tsteps)
206 {
207  m_tstep = stepsize;
208  m_steps.resize(n);
209  for (size_t i = 0; i < n; i++) {
210  m_steps[i] = tsteps[i];
211  }
212 }
213 
214 int Sim1D::newtonSolve(int loglevel)
215 {
216  int m = OneDim::solve(DATA_PTR(m_x), DATA_PTR(m_xnew), loglevel);
217  if (m >= 0) {
218  copy(m_xnew.begin(), m_xnew.end(), m_x.begin());
219  return 0;
220  } else if (m > -10) {
221  return -1;
222  } else {
223  throw CanteraError("Sim1D::newtonSolve",
224  "ERROR: OneDim::solve returned m = " + int2str(m) + "\n");
225  }
226 }
227 
228 void Sim1D::solve(int loglevel, bool refine_grid)
229 {
230  int new_points = 1;
231  int nsteps;
232  doublereal dt = m_tstep;
233  int soln_number = -1;
234  finalize();
235 
236  while (new_points > 0) {
237  size_t istep = 0;
238  nsteps = m_steps[istep];
239 
240  bool ok = false;
241  if (loglevel > 0) {
242  writelog("\n");
243  sim1D_drawline();
244  }
245  while (!ok) {
246  writelog("Attempt Newton solution of steady-state problem...", loglevel);
247  int status = newtonSolve(loglevel-1);
248 
249  if (status == 0) {
250  if (loglevel > 0) {
251  writelog(" success.\n\n");
252  writelog("Problem solved on [");
253  for (size_t mm = 1; mm < nDomains(); mm+=2) {
254  writelog(int2str(domain(mm).nPoints()));
255  if (mm + 2 < nDomains()) {
256  writelog(", ");
257  }
258  }
259  writelog("] point grid(s).\n");
260  }
261  if (loglevel > 6) {
262  save("debug_sim1d.xml", "debug",
263  "After successful Newton solve");
264  }
265  if (loglevel > 7) {
266  saveResidual("debug_sim1d.xml", "residual",
267  "After successful Newton solve");
268  }
269  ok = true;
270  soln_number++;
271  } else {
272  char buf[100];
273  writelog(" failure. \n", loglevel);
274  if (loglevel > 6) {
275  save("debug_sim1d.xml", "debug",
276  "After unsuccessful Newton solve");
277  }
278  if (loglevel > 7) {
279  saveResidual("debug_sim1d.xml", "residual",
280  "After unsuccessful Newton solve");
281  }
282  writelog("Take "+int2str(nsteps)+" timesteps ", loglevel);
283  dt = timeStep(nsteps, dt, DATA_PTR(m_x), DATA_PTR(m_xnew),
284  loglevel-1);
285  if (loglevel > 6) {
286  save("debug_sim1d.xml", "debug", "After timestepping");
287  }
288  if (loglevel > 7) {
289  saveResidual("debug_sim1d.xml", "residual",
290  "After timestepping");
291  }
292 
293  if (loglevel == 1) {
294  sprintf(buf, " %10.4g %10.4g \n", dt,
295  log10(ssnorm(DATA_PTR(m_x), DATA_PTR(m_xnew))));
296  writelog(buf);
297  }
298  istep++;
299  if (istep >= m_steps.size()) {
300  nsteps = m_steps.back();
301  } else {
302  nsteps = m_steps[istep];
303  }
304  if (dt > m_tmax) {
305  dt = m_tmax;
306  }
307  }
308  }
309  if (loglevel > 0) {
310  sim1D_drawline();
311  writelog("\n");
312  }
313  if (loglevel > 2) {
314  showSolution();
315  }
316 
317  if (refine_grid) {
318  new_points = refine(loglevel);
319  if (new_points) {
320  // If the grid has changed, preemptively reduce the timestep
321  // to avoid multiple successive failed time steps.
322  dt = m_tstep;
323  }
324  if (new_points && loglevel > 6) {
325  save("debug_sim1d.xml", "debug", "After regridding");
326  }
327  if (new_points && loglevel > 7) {
328  saveResidual("debug_sim1d.xml", "residual",
329  "After regridding");
330  }
331  if (new_points < 0) {
332  writelog("Maximum number of grid points reached.");
333  new_points = 0;
334  }
335  } else {
336  writelog("grid refinement disabled.\n", loglevel);
337  new_points = 0;
338  }
339  }
340 }
341 
342 int Sim1D::refine(int loglevel)
343 {
344  int ianalyze, np = 0;
345  vector_fp znew, xnew;
346  doublereal xmid, zmid;
347  std::vector<size_t> dsize;
348 
349  for (size_t n = 0; n < m_nd; n++) {
350  Domain1D& d = domain(n);
351  Refiner& r = d.refiner();
352 
353  // determine where new points are needed
354  ianalyze = r.analyze(d.grid().size(),
355  DATA_PTR(d.grid()), DATA_PTR(m_x) + start(n));
356  if (ianalyze < 0) {
357  return ianalyze;
358  }
359 
360  if (loglevel > 0) {
361  r.show();
362  }
363 
364  np += r.nNewPoints();
365  size_t comp = d.nComponents();
366 
367  // loop over points in the current grid
368  size_t npnow = d.nPoints();
369  size_t nstart = znew.size();
370  for (size_t m = 0; m < npnow; m++) {
371 
372  if (r.keepPoint(m)) {
373  // add the current grid point to the new grid
374  znew.push_back(d.grid(m));
375 
376  // do the same for the solution at this point
377  for (size_t i = 0; i < comp; i++) {
378  xnew.push_back(value(n, i, m));
379  }
380 
381  // now check whether a new point is needed in the
382  // interval to the right of point m, and if so, add
383  // entries to znew and xnew for this new point
384 
385  if (r.newPointNeeded(m) && m + 1 < npnow) {
386 
387  // add new point at midpoint
388  zmid = 0.5*(d.grid(m) + d.grid(m+1));
389  znew.push_back(zmid);
390  np++;
391  //writelog(string("refine: adding point at ")+fp2str(zmid)+"\n");
392 
393  // for each component, linearly interpolate
394  // the solution to this point
395  for (size_t i = 0; i < comp; i++) {
396  xmid = 0.5*(value(n, i, m) + value(n, i, m+1));
397  xnew.push_back(xmid);
398  }
399  }
400  } else {
401  writelog("refine: discarding point at "+fp2str(d.grid(m))+"\n", loglevel);
402  }
403  }
404  dsize.push_back(znew.size() - nstart);
405  }
406 
407  // At this point, the new grid znew and the new solution
408  // vector xnew have been constructed, but the domains
409  // themselves have not yet been modified. Now update each
410  // domain with the new grid.
411 
412  size_t gridstart = 0, gridsize;
413  for (size_t n = 0; n < m_nd; n++) {
414  Domain1D& d = domain(n);
415  // Refiner& r = d.refiner();
416  gridsize = dsize[n]; // d.nPoints() + r.nNewPoints();
417  d.setupGrid(gridsize, DATA_PTR(znew) + gridstart);
418  gridstart += gridsize;
419  }
420 
421  // Replace the current solution vector with the new one
422  m_x.resize(xnew.size());
423  copy(xnew.begin(), xnew.end(), m_x.begin());
424 
425  // resize the work array
426  m_xnew.resize(xnew.size());
427 
428  // copy(xnew.begin(), xnew.end(), m_xnew.begin());
429 
430  resize();
431  finalize();
432  return np;
433 }
434 
435 int Sim1D::setFixedTemperature(doublereal t)
436 {
437  int np = 0;
438  vector_fp znew, xnew;
439  doublereal xmid;
440  doublereal zfixed,interp_factor;
441  doublereal z1 = 0.0, z2 = 0.0, t1,t2;
442  size_t n, m, i;
443  size_t m1 = 0;
444  std::vector<size_t> dsize;
445 
446 
447  for (n = 0; n < m_nd; n++) {
448  bool addnewpt=false;
449  Domain1D& d = domain(n);
450 
451  size_t comp = d.nComponents();
452 
453  // loop over points in the current grid to determine where new point is needed.
454  size_t npnow = d.nPoints();
455  size_t nstart = znew.size();
456  for (m = 0; m < npnow-1; m++) {
457  if (value(n,2,m) == t) {
458  zfixed = d.grid(m);
459  //set d.zfixed, d.ztemp
460  d.m_zfixed = zfixed;
461  d.m_tfixed = t;
462  addnewpt = false;
463  break;
464  } else if ((value(n,2,m)<t) && (value(n,2,m+1)>t)) {
465  z1 = d.grid(m);
466  m1 = m;
467  z2 = d.grid(m+1);
468  t1 = value(n,2,m);
469  t2 = value(n,2,m+1);
470 
471  zfixed = (z1-z2)/(t1-t2)*(t-t2)+z2;
472  //set d.zfixed, d.ztemp;
473  d.m_zfixed = zfixed;
474  d.m_tfixed = t;
475  addnewpt = true;
476  break;
477  //copy solution domain and push back values
478  }
479  }
480 
481 
482  for (m = 0; m < npnow; m++) {
483  // add the current grid point to the new grid
484  znew.push_back(d.grid(m));
485 
486  // do the same for the solution at this point
487  for (i = 0; i < comp; i++) {
488  xnew.push_back(value(n, i, m));
489  }
490  if (m==m1 && addnewpt) {
491  //add new point at zfixed
492  znew.push_back(zfixed);
493  np++;
494  interp_factor = (zfixed-z2) / (z1-z2);
495  // for each component, linearly interpolate
496  // the solution to this point
497  for (i = 0; i < comp; i++) {
498  xmid = interp_factor*(value(n, i, m) - value(n, i, m+1)) + value(n,i,m+1);
499  xnew.push_back(xmid);
500  }
501  }
502 
503 
504  }
505  dsize.push_back(znew.size() - nstart);
506  }
507 
508  // At this point, the new grid znew and the new solution
509  // vector xnew have been constructed, but the domains
510  // themselves have not yet been modified. Now update each
511  // domain with the new grid.
512 
513  size_t gridstart = 0, gridsize;
514  for (n = 0; n < m_nd; n++) {
515  Domain1D& d = domain(n);
516  // Refiner& r = d.refiner();
517  gridsize = dsize[n]; // d.nPoints() + r.nNewPoints();
518  d.setupGrid(gridsize, DATA_PTR(znew) + gridstart);
519  gridstart += gridsize;
520  }
521 
522  // Replace the current solution vector with the new one
523  m_x.resize(xnew.size());
524  copy(xnew.begin(), xnew.end(), m_x.begin());
525 
526  // resize the work array
527  m_xnew.resize(xnew.size());
528 
529  copy(xnew.begin(), xnew.end(), m_xnew.begin());
530 
531  resize();
532  finalize();
533  return np;
534 }
535 
536 void Sim1D::setAdiabaticFlame(void)
537 {
538  for (size_t n = 0; n < m_nd; n++) {
539  Domain1D& d = domain(n);
540  d.m_adiabatic=true;
541  }
542 }
543 
544 void Sim1D::setRefineCriteria(int dom, doublereal ratio,
545  doublereal slope, doublereal curve, doublereal prune)
546 {
547  if (dom >= 0) {
548  Refiner& r = domain(dom).refiner();
549  r.setCriteria(ratio, slope, curve, prune);
550  } else {
551  for (size_t n = 0; n < m_nd; n++) {
552  Refiner& r = domain(n).refiner();
553  r.setCriteria(ratio, slope, curve, prune);
554  }
555  }
556 }
557 
558 void Sim1D::setGridMin(int dom, double gridmin)
559 {
560  if (dom >= 0) {
561  Refiner& r = domain(dom).refiner();
562  r.setGridMin(gridmin);
563  } else {
564  for (size_t n = 0; n < m_nd; n++) {
565  Refiner& r = domain(n).refiner();
566  r.setGridMin(gridmin);
567  }
568  }
569 }
570 
571 void Sim1D::setMaxGridPoints(int dom, int npoints)
572 {
573  if (dom >= 0) {
574  Refiner& r = domain(dom).refiner();
575  r.setMaxPoints(npoints);
576  } else {
577  for (size_t n = 0; n < m_nd; n++) {
578  Refiner& r = domain(n).refiner();
579  r.setMaxPoints(npoints);
580  }
581  }
582 }
583 
584 doublereal Sim1D::jacobian(int i, int j)
585 {
586  return OneDim::jacobian().value(i,j);
587 }
588 
589 void Sim1D::evalSSJacobian()
590 {
591  OneDim::evalSSJacobian(DATA_PTR(m_x), DATA_PTR(m_xnew));
592 }
593 }
Container class for multiple-domain 1D problems.
Definition: OneDim.h:22
size_t m_nd
number of domains
Definition: OneDim.h:266
void showSolution(std::ostream &s)
Print to stream s the current solution for all domains.
Definition: Sim1D.cpp:171
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:40
virtual void _getInitialSoln(doublereal *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition: Domain1D.cpp:273
size_t nPoints() const
Number of grid points in this domain.
Definition: Domain1D.h:186
void restore(const std::string &fname, const std::string &id, int loglevel=2)
Initialize the solution with a previously-saved solution.
Definition: Sim1D.cpp:120
double timeStep(int nsteps, double dt, double *x, double *r, int loglevel)
Definition: OneDim.cpp:331
vector_fp m_x
the solution vector
Definition: Sim1D.h:163
void resize()
Call after one or more grids has been refined.
Definition: OneDim.cpp:139
doublereal value(size_t dom, size_t comp, size_t localPoint) const
Get one entry in the solution vector.
Definition: Sim1D.cpp:72
doublereal ssnorm(doublereal *x, doublereal *r)
Steady-state max norm (infinity norm) of the residual evaluated using solution x. ...
Definition: OneDim.cpp:268
void eval(size_t j, double *x, double *r, doublereal rdt=-1.0, int count=1)
Evaluate the multi-domain residual function.
Definition: OneDim.cpp:236
MultiJac & jacobian()
Return a reference to the Jacobian evaluator.
Definition: OneDim.cpp:94
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
Definition: Domain1D.h:208
void setValue(size_t dom, size_t comp, size_t localPoint, doublereal value)
Set a single value in the solution vector.
Definition: Sim1D.cpp:63
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
Definition: Domain1D.h:461
void setRefineCriteria(int dom=-1, doublereal ratio=10.0, doublereal slope=0.8, doublereal curve=0.8, doublereal prune=-0.1)
Set grid refinement criteria.
Definition: Sim1D.cpp:544
int solve(doublereal *x0, doublereal *x1, int loglevel)
Solve F(x) = 0, where F(x) is the multi-domain residual function.
Definition: OneDim.cpp:203
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
void setInitialGuess(const std::string &component, vector_fp &locs, vector_fp &vals)
Set initial guess based on equilibrium.
Definition: Sim1D.cpp:50
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Domain1D.cpp:167
size_t loc(size_t jg)
Location in the solution vector of the first component of global point jg.
Definition: OneDim.h:106
vector_int m_steps
array of number of steps to take before re-attempting the steady-state solution
Definition: Sim1D.h:173
int newtonSolve(int loglevel)
Definition: Sim1D.cpp:214
#define AssertThrowMsg(expr, procedure, message)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:247
size_t nComponents() const
Number of components at each grid point.
Definition: Domain1D.h:164
Base class for one-dimensional domains.
Definition: Domain1D.h:37
int setFixedTemperature(doublereal t)
Add node for fixed temperature point of freely propagating flame.
Definition: Sim1D.cpp:435
void setCriteria(doublereal ratio=10.0, doublereal slope=0.8, doublereal curve=0.8, doublereal prune=-0.1)
Set grid refinement criteria.
Definition: refine.h:31
size_t start(size_t i) const
The index of the start of domain i in the solution vector.
Definition: OneDim.h:78
void setMaxPoints(int npmax)
Set the maximum number of points allowed in the domain.
Definition: refine.h:45
Domain1D & domain(size_t i) const
Return a reference to domain i.
Definition: OneDim.h:54
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Definition: stringUtils.cpp:29
void finalize()
Calls method _finalize in each domain.
Definition: Sim1D.cpp:198
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate...
Definition: Domain1D.h:605
virtual void showSolution(const doublereal *x)
Print the solution.
Definition: Domain1D.cpp:225
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
doublereal m_tstep
timestep
Definition: Sim1D.h:169
doublereal & value(size_t i, size_t j)
Return a changeable reference to element (i,j).
Definition: BandMatrix.cpp:138
size_t nDomains() const
Number of domains.
Definition: OneDim.h:49
void setGridMin(double gridmin)
Set the minimum allowable spacing between adjacent grid points [m].
Definition: refine.h:50
void setFlatProfile(size_t dom, size_t comp, doublereal v)
Set component 'comp' of domain 'dom' to value 'v' at all points.
Definition: Sim1D.cpp:162
Refiner & refiner()
Return a reference to the grid refiner.
Definition: Domain1D.h:159
Sim1D()
Default constructor.
Definition: Sim1D.cpp:22
int intValue(const std::string &val)
Translate a string into one integer value.
vector_fp m_xnew
a work array used to hold the residual or the new solution
Definition: Sim1D.h:166
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
int refine(int loglevel=0)
Refine the grid in all domains.
Definition: Sim1D.cpp:342
XML_Node * findID(const std::string &id, const int depth=100) const
This routine carries out a recursive search for an XML node based on the xml element attribute...
Definition: xml.cpp:697
void setProfile(size_t dom, size_t comp, const vector_fp &pos, const vector_fp &values)
Specify a profile for one component of one domain.
Definition: Sim1D.cpp:90
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
Definition: ct_defs.h:36
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Definition: refine.h:13
void writelog(const std::string &msg)
Write a message to the screen.
Definition: global.cpp:43
size_t size() const
Total solution vector length;.
Definition: OneDim.h:83
void setGridMin(int dom, double gridmin)
Set the minimum grid spacing in the specified domain(s).
Definition: Sim1D.cpp:558
void build(std::istream &f)
Main routine to create an tree-like representation of an XML file.
Definition: xml.cpp:776
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
Definition: Domain1D.cpp:209
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...
Definition: xml.cpp:916
doublereal linearInterp(doublereal x, const vector_fp &xpts, const vector_fp &fpts)
Linearly interpolate a function defined on a discrete grid.
Definition: funcs.cpp:40