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