Loading [MathJax]/extensions/tex2jax.js
Cantera  3.2.0a1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Domain1D.h
Go to the documentation of this file.
1 //! @file Domain1D.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_DOMAIN1D_H
7#define CT_DOMAIN1D_H
8
10#include "cantera/base/global.h"
11
12namespace Cantera
13{
14
15class MultiJac;
16class OneDim;
17class Refiner;
18class AnyMap;
19class Kinetics;
20class Transport;
21class Solution;
22class SolutionArray;
23
24/**
25 * Base class for one-dimensional domains.
26 * @ingroup flowGroup
27 */
29{
30public:
31 /**
32 * Constructor.
33 * @param nv Number of variables at each grid point.
34 * @param points Number of grid points.
35 * @param time (unused)
36 */
37 Domain1D(size_t nv=1, size_t points=1, double time=0.0);
38
39 virtual ~Domain1D();
40 Domain1D(const Domain1D&) = delete;
41 Domain1D& operator=(const Domain1D&) = delete;
42
43 //! Domain type flag.
44 //! @since Starting in %Cantera 3.1, the return type is a `string`.
45 virtual string domainType() const { return "domain"; }
46
47 //! String indicating the domain implemented.
48 //! @since New in %Cantera 3.0.
49 //! @deprecated Transitional method. Use domainType() instead.
50 string type() const { return domainType(); }
51
52 //! The left-to-right location of this domain.
53 size_t domainIndex() {
54 return m_index;
55 }
56
57 //! True if the domain is a connector domain.
58 virtual bool isConnector() {
59 return false;
60 }
61
62 //! Set the solution manager.
63 //! @since New in %Cantera 3.0.
64 void setSolution(shared_ptr<Solution> sol);
65
66 //! Set the kinetics manager.
67 //! @since New in %Cantera 3.0.
68 virtual void setKinetics(shared_ptr<Kinetics> kin) {
69 throw NotImplementedError("Domain1D::setKinetics");
70 }
71
72 //! Set transport model to existing instance
73 //! @since New in %Cantera 3.0.
74 virtual void setTransport(shared_ptr<Transport> trans) {
75 throw NotImplementedError("Domain1D::setTransport");
76 }
77
78 //! Set transport model by name.
79 //! @param model String specifying model name.
80 //! @since New in %Cantera 3.2.
81 virtual void setTransportModel(const string& model) {
82 throw NotImplementedError("Domain1D::setTransportModel");
83 }
84
85 //! The container holding this domain.
86 const OneDim& container() const {
87 return *m_container;
88 }
89
90 //! Specify the container object for this domain, and the position of this
91 //! domain in the list.
92 void setContainer(OneDim* c, size_t index) {
93 m_container = c;
94 m_index = index;
95 }
96
97 //! Set the Jacobian bandwidth. See the discussion of method bandwidth().
98 void setBandwidth(int bw = -1) {
99 m_bw = bw;
100 }
101
102 //! Set the Jacobian bandwidth for this domain.
103 /**
104 * When class OneDim computes the bandwidth of the overall multi-domain
105 * problem (in OneDim::resize()), it calls this method for the bandwidth
106 * of each domain. If setBandwidth has not been called, then a negative
107 * bandwidth is returned, in which case OneDim assumes that this domain is
108 * dense -- that is, at each point, all components depend on the value of
109 * all other components at that point. In this case, the bandwidth is bw =
110 * 2*nComponents() - 1. However, if this domain contains some components
111 * that are uncoupled from other components at the same point, then this
112 * default bandwidth may greatly overestimate the true bandwidth, with a
113 * substantial penalty in performance. For such domains, use method
114 * setBandwidth to specify the bandwidth before passing this domain to the
115 * Sim1D or OneDim constructor.
116 */
117 size_t bandwidth() {
118 return m_bw;
119 }
120
121 /**
122 * Initialize. This method is called by OneDim::init() for each domain once
123 * at the beginning of a simulation. Base class method does nothing, but may
124 * be overloaded.
125 */
126 virtual void init() { }
127
128 /**
129 * When called, this function should reset "bad" values in the state vector
130 * such as negative species concentrations. This function may be called
131 * after a failed solution attempt.
132 */
133 virtual void resetBadValues(double* xg) {}
134
135 /**
136 * Resize the domain to have nv components and np grid points. This method
137 * is virtual so that subclasses can perform other actions required to
138 * resize the domain.
139 */
140 virtual void resize(size_t nv, size_t np);
141
142 //! Return a reference to the grid refiner.
144 return *m_refiner;
145 }
146
147 //! Number of components at each grid point.
148 size_t nComponents() const {
149 return m_nv;
150 }
151
152 //! Check that the specified component index is in range.
153 //! Throws an exception if n is greater than nComponents()-1
154 void checkComponentIndex(size_t n) const {
155 if (n >= m_nv) {
156 throw IndexError("Domain1D::checkComponentIndex", "points", n, m_nv);
157 }
158 }
159
160 //! Check that an array size is at least nComponents().
161 //! Throws an exception if nn is less than nComponents(). Used before calls
162 //! which take an array pointer.
163 void checkComponentArraySize(size_t nn) const {
164 if (m_nv > nn) {
165 throw ArraySizeError("Domain1D::checkComponentArraySize", nn, m_nv);
166 }
167 }
168
169 //! Number of grid points in this domain.
170 size_t nPoints() const {
171 return m_points;
172 }
173
174 //! Check that the specified point index is in range.
175 //! Throws an exception if n is greater than nPoints()-1
176 void checkPointIndex(size_t n) const {
177 if (n >= m_points) {
178 throw IndexError("Domain1D::checkPointIndex", "points", n, m_points);
179 }
180 }
181
182 //! Check that an array size is at least nPoints().
183 //! Throws an exception if nn is less than nPoints(). Used before calls
184 //! which take an array pointer.
185 void checkPointArraySize(size_t nn) const {
186 if (m_points > nn) {
187 throw ArraySizeError("Domain1D::checkPointArraySize", nn, m_points);
188 }
189 }
190
191 //! Name of component `n`. May be overloaded.
192 virtual string componentName(size_t n) const;
193
194 //! Set the name of the component `n` to `name`.
195 void setComponentName(size_t n, const string& name) {
196 m_name[n] = name;
197 }
198
199 //! index of component with name `name`.
200 virtual size_t componentIndex(const string& name) const;
201
202 /**
203 * Set the upper and lower bounds for a solution component, n.
204 *
205 * @param n solution component index
206 * @param lower lower bound on component n
207 * @param upper upper bound on component n
208 */
209 void setBounds(size_t n, double lower, double upper) {
210 m_min[n] = lower;
211 m_max[n] = upper;
212 }
213
214 //! Set tolerances for time-stepping mode
215 /*!
216 * @param rtol Relative tolerance
217 * @param atol Absolute tolerance
218 * @param n component index these tolerances apply to. If set to -1 (the
219 * default), these tolerances will be applied to all solution
220 * components.
221 */
222 void setTransientTolerances(double rtol, double atol, size_t n=npos);
223
224 //! Set tolerances for steady-state mode
225 /*!
226 * @param rtol Relative tolerance
227 * @param atol Absolute tolerance
228 * @param n component index these tolerances apply to. If set to -1 (the
229 * default), these tolerances will be applied to all solution
230 * components.
231 */
232 void setSteadyTolerances(double rtol, double atol, size_t n=npos);
233
234 //! Relative tolerance of the nth component.
235 double rtol(size_t n) {
236 return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]);
237 }
238
239 //! Absolute tolerance of the nth component.
240 double atol(size_t n) {
241 return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]);
242 }
243
244 //! Steady relative tolerance of the nth component
245 double steady_rtol(size_t n) {
246 return m_rtol_ss[n];
247 }
248
249 //! Steady absolute tolerance of the nth component
250 double steady_atol(size_t n) {
251 return m_atol_ss[n];
252 }
253
254 //! Transient relative tolerance of the nth component
255 double transient_rtol(size_t n) {
256 return m_rtol_ts[n];
257 }
258
259 //! Transient absolute tolerance of the nth component
260 double transient_atol(size_t n) {
261 return m_atol_ts[n];
262 }
263
264 //! Upper bound on the nth component.
265 double upperBound(size_t n) const {
266 return m_max[n];
267 }
268
269 //! Lower bound on the nth component
270 double lowerBound(size_t n) const {
271 return m_min[n];
272 }
273
274 /**
275 * Performs the setup required before starting a time-stepping solution.
276 * Stores the solution provided in `x0` to the internal storage, and sets
277 * the reciprocal of the time step to `1/dt`.
278 *
279 * @param[in] dt Time step
280 * @param[in] x0 Array to store the solution at the last time step
281 */
282 void initTimeInteg(double dt, const double* x0) {
283 std::copy(x0 + loc(), x0 + loc() + size(), m_slast.begin());
284 m_rdt = 1.0/dt;
285 }
286
287 /**
288 * Set the internally-stored reciprocal of the time step to 0.0, which is
289 * used to indicate that the problem is in steady-state mode.
290 */
292 m_rdt = 0.0;
293 }
294
295 //! True if in steady-state mode
296 bool steady() {
297 return (m_rdt == 0.0);
298 }
299
300 //! True if not in steady-state mode
301 bool transient() {
302 return (m_rdt != 0.0);
303 }
304
305 /**
306 * Set this if something has changed in the governing
307 * equations (for example, the value of a constant has been changed,
308 * so that the last-computed Jacobian is no longer valid.
309 */
310 void needJacUpdate();
311
312 //! Evaluate the residual function at point j. If j == npos,
313 //! evaluate the residual function at all points.
314 /*!
315 * This function must be implemented in classes derived from Domain1D.
316 *
317 * @param[in] j Grid point at which to update the residual
318 * @param[in] x State vector
319 * @param[out] r residual vector
320 * @param[out] mask Boolean mask indicating whether each solution
321 * component has a time derivative (1) or not (0).
322 * @param[in] rdt Reciprocal of the timestep (`rdt=0` implies steady-state.)
323 */
324 virtual void eval(size_t j, double* x, double* r, integer* mask, double rdt=0.0) {
325 throw NotImplementedError("Domain1D::eval");
326 }
327
328 /**
329 * Returns the index of the solution vector, which corresponds to component
330 * n at grid point j.
331 *
332 * @param n component index
333 * @param j grid point index
334 */
335 size_t index(size_t n, size_t j) const {
336 return m_nv*j + n;
337 }
338
339 /**
340 * Returns the value of solution component n at grid point j of the solution
341 * vector x.
342 *
343 * @param x solution vector
344 * @param n component index
345 * @param j grid point index
346 */
347 double value(const double* x, size_t n, size_t j) const {
348 return x[index(n,j)];
349 }
350
351 //! Save the state of this domain as a SolutionArray.
352 /*!
353 * @param soln local solution vector for this domain
354 * @todo Despite the method's name, data are copied; the intent is to access data
355 * directly in future revisions, where a non-const version will be implemented.
356 *
357 * @since New in %Cantera 3.0.
358 */
359 virtual shared_ptr<SolutionArray> asArray(const double* soln) const {
360 throw NotImplementedError("Domain1D::asArray", "Needs to be overloaded.");
361 }
362
363 //! Save the state of this domain to a SolutionArray.
364 /*!
365 * This method serves as an external interface for high-level API's; it does not
366 * provide direct access to memory.
367 * @param normalize If true, normalize concentrations (default=false)
368 *
369 * @since New in %Cantera 3.0.
370 */
371 shared_ptr<SolutionArray> toArray(bool normalize=false) const;
372
373 //! Restore the solution for this domain from a SolutionArray
374 /*!
375 * @param[in] arr SolutionArray defining the state of this domain
376 * @param[out] soln Value of the solution vector, local to this domain
377 *
378 * @since New in %Cantera 3.0.
379 */
380 virtual void fromArray(SolutionArray& arr, double* soln) {
381 throw NotImplementedError("Domain1D::fromArray", "Needs to be overloaded.");
382 }
383
384 //! Restore the solution for this domain from a SolutionArray.
385 /*!
386 * This method serves as an external interface for high-level API's.
387 * @param arr SolutionArray defining the state of this domain
388 * @since New in %Cantera 3.0.
389 */
390 void fromArray(const shared_ptr<SolutionArray>& arr);
391
392 //! Return thermo/kinetics/transport manager used in the domain
393 //! @since New in %Cantera 3.0.
394 shared_ptr<Solution> solution() const {
395 return m_solution;
396 }
397
398 //! Return the size of the solution vector (the product of #m_nv and #m_points).
399 size_t size() const {
400 return m_nv*m_points;
401 }
402
403 /**
404 * Find the index of the first grid point in this domain, and
405 * the start of its variables in the global solution vector.
406 */
407 void locate();
408
409 //! Location of the start of the local solution vector in the global solution vector
410 virtual size_t loc(size_t j = 0) const {
411 return m_iloc;
412 }
413
414 //! The index of the first (that is, left-most) grid point belonging to this domain.
415 size_t firstPoint() const {
416 return m_jstart;
417 }
418
419 //! The index of the last (that is, right-most) grid point belonging to this domain.
420 size_t lastPoint() const {
421 return m_jstart + m_points - 1;
422 }
423
424 /**
425 * Set the left neighbor to domain 'left.' Method 'locate' is called to
426 * update the global positions of this domain and all those to its right.
427 */
429 m_left = left;
430 if (!m_solution && left && left->solution()) {
432 }
433 locate();
434 }
435
436 //! Set the right neighbor to domain 'right.'
438 m_right = right;
439 if (!m_solution && right && right->solution()) {
441 }
442 }
443
444 //! Append domain 'right' to this one, and update all links.
447 right->linkLeft(this);
448 }
449
450 //! Return a pointer to the left neighbor.
451 Domain1D* left() const {
452 return m_left;
453 }
454
455 //! Return a pointer to the right neighbor.
456 Domain1D* right() const {
457 return m_right;
458 }
459
460 //! Value of component n at point j in the previous solution.
461 double prevSoln(size_t n, size_t j) const {
462 return m_slast[m_nv*j + n];
463 }
464
465 //! Specify an identifying tag for this domain.
466 void setID(const string& s) {
467 m_id = s;
468 }
469
470 //! Returns the identifying tag for this domain.
471 string id() const {
472 if (m_id != "") {
473 return m_id;
474 } else {
475 return fmt::format("domain {}", m_index);
476 }
477 }
478
479 //! Print the solution.
480 //! @param x Pointer to the local portion of the system state vector
481 virtual void show(const double* x);
482
483 //! Get the coordinate [m] of the point with local index `jlocal`
484 double z(size_t jlocal) const {
485 return m_z[jlocal];
486 }
487
488 //! Get the coordinate [m] of the first (leftmost) grid point in this domain
489 double zmin() const {
490 return m_z[0];
491 }
492
493 //! Get the coordinate [m] of the last (rightmost) grid point in this domain
494 double zmax() const {
495 return m_z[m_points - 1];
496 }
497
498 //! Set initial values for a component at each grid point
499 //! @param name Name of the component
500 //! @param values Array of length nPoints() containing the initial values
501 //! @param soln Pointer to the local portion of the system state vector
502 void setProfile(const string& name, double* values, double* soln);
503
504 //! Access the array of grid coordinates [m]
505 vector<double>& grid() {
506 return m_z;
507 }
508
509 //! Access the array of grid coordinates [m]
510 const vector<double>& grid() const {
511 return m_z;
512 }
513
514 //! called to set up initial grid, and after grid refinement
515 virtual void setupGrid(size_t n, const double* z);
516
517 /**
518 * Writes some or all initial solution values into the global solution
519 * array, beginning at the location pointed to by x. This method is called
520 * by the Sim1D constructor, and allows default values or ones that have
521 * been set locally prior to installing this domain into the container to be
522 * written to the global solution vector.
523 */
524 virtual void _getInitialSoln(double* x);
525
526 //! Initial value of solution component @e n at grid point @e j.
527 virtual double initialValue(size_t n, size_t j);
528
529 /**
530 * In some cases, a domain may need to set parameters that depend on the
531 * initial solution estimate. In such cases, the parameters may be set in
532 * method _finalize. This method is called just before the Newton solver is
533 * called, and the x array is guaranteed to be the local solution vector for
534 * this domain that will be used as the initial guess. If no such parameters
535 * need to be set, then method _finalize does not need to be overloaded.
536 */
537 virtual void _finalize(const double* x) {}
538
539 /**
540 * In some cases, for computational efficiency some properties (such as
541 * transport coefficients) may not be updated during Jacobian evaluations.
542 * Set this to `true` to force these properties to be updated even while
543 * calculating Jacobian elements.
544 */
545 void forceFullUpdate(bool update) {
546 m_force_full_update = update;
547 }
548
549 //! Set shared data pointer
550 void setData(shared_ptr<vector<double>>& data) {
551 m_state = data;
552 }
553
554protected:
555 //! Retrieve meta data
556 virtual AnyMap getMeta() const;
557
558 //! Retrieve meta data
559 virtual void setMeta(const AnyMap& meta);
560
561 shared_ptr<vector<double>> m_state; //!< data pointer shared from OneDim
562
563 double m_rdt = 0.0; //!< Reciprocal of the time step
564 size_t m_nv = 0; //!< Number of solution components
565 size_t m_points; //!< Number of grid points
566 vector<double> m_slast; //!< Solution vector at the last time step
567 vector<double> m_max; //!< Upper bounds on solution components
568 vector<double> m_min; //!< Lower bounds on solution components
569 vector<double> m_rtol_ss; //!< Relative tolerances for steady mode
570 vector<double> m_rtol_ts; //!< Relative tolerances for transient mode
571 vector<double> m_atol_ss; //!< Absolute tolerances for steady mode
572 vector<double> m_atol_ts; //!< Absolute tolerances for transient mode
573 vector<double> m_z; //!< 1D spatial grid coordinates
574
575 //! Parent OneDim simulation containing this and adjacent domains
576 OneDim* m_container = nullptr;
577
578 size_t m_index; //!< Left-to-right location of this domain
579
580 //! Starting location within the solution vector for unknowns that
581 //! correspond to this domain
582 /*!
583 * Remember there may be multiple domains associated with this problem
584 */
585 size_t m_iloc = 0;
586
587 //! Index of the first point in this domain in the global point list.
588 //! @see firstPoint(), lastPoint()
589 size_t m_jstart = 0;
590
591 Domain1D* m_left = nullptr; //!< Pointer to the domain to the left
592 Domain1D* m_right = nullptr; //!< Pointer to the domain to the right
593
594 //! Identity tag for the domain
595 string m_id;
596 unique_ptr<Refiner> m_refiner; //!< Refiner object used for placing grid points
597 vector<string> m_name; //!< Names of solution components
598 int m_bw = -1; //!< See bandwidth()
599 bool m_force_full_update = false; //!< see forceFullUpdate()
600
601 //! Composite thermo/kinetics/transport handler
602 shared_ptr<Solution> m_solution;
603};
604}
605
606#endif
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:432
Array size error.
Base class for one-dimensional domains.
Definition Domain1D.h:29
void setTransientTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for time-stepping mode.
Definition Domain1D.cpp:87
virtual void resetBadValues(double *xg)
When called, this function should reset "bad" values in the state vector such as negative species con...
Definition Domain1D.h:133
size_t lastPoint() const
The index of the last (that is, right-most) grid point belonging to this domain.
Definition Domain1D.h:420
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain.
Definition Domain1D.h:585
void checkPointArraySize(size_t nn) const
Check that an array size is at least nPoints().
Definition Domain1D.h:185
size_t domainIndex()
The left-to-right location of this domain.
Definition Domain1D.h:53
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
Definition Domain1D.h:602
Domain1D * m_left
Pointer to the domain to the left.
Definition Domain1D.h:591
OneDim * m_container
Parent OneDim simulation containing this and adjacent domains.
Definition Domain1D.h:576
bool transient()
True if not in steady-state mode.
Definition Domain1D.h:301
void setComponentName(size_t n, const string &name)
Set the name of the component n to name.
Definition Domain1D.h:195
size_t nComponents() const
Number of components at each grid point.
Definition Domain1D.h:148
size_t bandwidth()
Set the Jacobian bandwidth for this domain.
Definition Domain1D.h:117
double rtol(size_t n)
Relative tolerance of the nth component.
Definition Domain1D.h:235
shared_ptr< Solution > solution() const
Return thermo/kinetics/transport manager used in the domain.
Definition Domain1D.h:394
vector< double > m_atol_ss
Absolute tolerances for steady mode.
Definition Domain1D.h:571
vector< double > m_rtol_ts
Relative tolerances for transient mode.
Definition Domain1D.h:570
size_t size() const
Return the size of the solution vector (the product of m_nv and m_points).
Definition Domain1D.h:399
vector< double > m_atol_ts
Absolute tolerances for transient mode.
Definition Domain1D.h:572
virtual bool isConnector()
True if the domain is a connector domain.
Definition Domain1D.h:58
virtual void setTransport(shared_ptr< Transport > trans)
Set transport model to existing instance.
Definition Domain1D.h:74
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
Definition Domain1D.cpp:173
virtual void _finalize(const double *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
Definition Domain1D.h:537
size_t m_index
Left-to-right location of this domain.
Definition Domain1D.h:578
Domain1D * left() const
Return a pointer to the left neighbor.
Definition Domain1D.h:451
string id() const
Returns the identifying tag for this domain.
Definition Domain1D.h:471
vector< double > & grid()
Access the array of grid coordinates [m].
Definition Domain1D.h:505
double zmin() const
Get the coordinate [m] of the first (leftmost) grid point in this domain.
Definition Domain1D.h:489
size_t m_jstart
Index of the first point in this domain in the global point list.
Definition Domain1D.h:589
size_t m_nv
Number of solution components.
Definition Domain1D.h:564
void setContainer(OneDim *c, size_t index)
Specify the container object for this domain, and the position of this domain in the list.
Definition Domain1D.h:92
size_t nPoints() const
Number of grid points in this domain.
Definition Domain1D.h:170
vector< string > m_name
Names of solution components.
Definition Domain1D.h:597
double m_rdt
Reciprocal of the time step.
Definition Domain1D.h:563
virtual string domainType() const
Domain type flag.
Definition Domain1D.h:45
bool m_force_full_update
see forceFullUpdate()
Definition Domain1D.h:599
double lowerBound(size_t n) const
Lower bound on the nth component.
Definition Domain1D.h:270
virtual void setTransportModel(const string &model)
Set transport model by name.
Definition Domain1D.h:81
void checkComponentIndex(size_t n) const
Check that the specified component index is in range.
Definition Domain1D.h:154
shared_ptr< vector< double > > m_state
data pointer shared from OneDim
Definition Domain1D.h:561
void linkLeft(Domain1D *left)
Set the left neighbor to domain 'left.
Definition Domain1D.h:428
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
Definition Domain1D.cpp:44
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:484
double upperBound(size_t n) const
Upper bound on the nth component.
Definition Domain1D.h:265
Refiner & refiner()
Return a reference to the grid refiner.
Definition Domain1D.h:143
Domain1D * right() const
Return a pointer to the right neighbor.
Definition Domain1D.h:456
virtual void show(const double *x)
Print the solution.
Definition Domain1D.cpp:235
vector< double > m_rtol_ss
Relative tolerances for steady mode.
Definition Domain1D.h:569
vector< double > m_slast
Solution vector at the last time step.
Definition Domain1D.h:566
Domain1D * m_right
Pointer to the domain to the right.
Definition Domain1D.h:592
double steady_atol(size_t n)
Steady absolute tolerance of the nth component.
Definition Domain1D.h:250
void setSteadyTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for steady-state mode.
Definition Domain1D.cpp:100
virtual shared_ptr< SolutionArray > asArray(const double *soln) const
Save the state of this domain as a SolutionArray.
Definition Domain1D.h:359
virtual string componentName(size_t n) const
Name of component n. May be overloaded.
Definition Domain1D.cpp:67
double transient_atol(size_t n)
Transient absolute tolerance of the nth component.
Definition Domain1D.h:260
void setSolution(shared_ptr< Solution > sol)
Set the solution manager.
Definition Domain1D.cpp:31
virtual void init()
Initialize.
Definition Domain1D.h:126
double atol(size_t n)
Absolute tolerance of the nth component.
Definition Domain1D.h:240
void setProfile(const string &name, double *values, double *soln)
Set initial values for a component at each grid point.
Definition Domain1D.cpp:271
void setID(const string &s)
Specify an identifying tag for this domain.
Definition Domain1D.h:466
vector< double > m_z
1D spatial grid coordinates
Definition Domain1D.h:573
void forceFullUpdate(bool update)
In some cases, for computational efficiency some properties (such as transport coefficients) may not ...
Definition Domain1D.h:545
const vector< double > & grid() const
Access the array of grid coordinates [m].
Definition Domain1D.h:510
const OneDim & container() const
The container holding this domain.
Definition Domain1D.h:86
virtual void setKinetics(shared_ptr< Kinetics > kin)
Set the kinetics manager.
Definition Domain1D.h:68
shared_ptr< SolutionArray > toArray(bool normalize=false) const
Save the state of this domain to a SolutionArray.
Definition Domain1D.cpp:149
size_t m_points
Number of grid points.
Definition Domain1D.h:565
bool steady()
True if in steady-state mode.
Definition Domain1D.h:296
void setBandwidth(int bw=-1)
Set the Jacobian bandwidth. See the discussion of method bandwidth().
Definition Domain1D.h:98
double steady_rtol(size_t n)
Steady relative tolerance of the nth component.
Definition Domain1D.h:245
string m_id
Identity tag for the domain.
Definition Domain1D.h:595
string type() const
String indicating the domain implemented.
Definition Domain1D.h:50
vector< double > m_max
Upper bounds on solution components.
Definition Domain1D.h:567
unique_ptr< Refiner > m_refiner
Refiner object used for placing grid points.
Definition Domain1D.h:596
void initTimeInteg(double dt, const double *x0)
Performs the setup required before starting a time-stepping solution.
Definition Domain1D.h:282
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
Definition Domain1D.h:209
vector< double > m_min
Lower bounds on solution components.
Definition Domain1D.h:568
void setData(shared_ptr< vector< double > > &data)
Set shared data pointer.
Definition Domain1D.h:550
virtual void eval(size_t j, double *x, double *r, integer *mask, double rdt=0.0)
Evaluate the residual function at point j.
Definition Domain1D.h:324
void append(Domain1D *right)
Append domain 'right' to this one, and update all links.
Definition Domain1D.h:445
double value(const double *x, size_t n, size_t j) const
Returns the value of solution component n at grid point j of the solution vector x.
Definition Domain1D.h:347
void setSteadyMode()
Set the internally-stored reciprocal of the time step to 0.0, which is used to indicate that the prob...
Definition Domain1D.h:291
virtual double initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
Definition Domain1D.cpp:293
void checkPointIndex(size_t n) const
Check that the specified point index is in range.
Definition Domain1D.h:176
virtual size_t componentIndex(const string &name) const
index of component with name name.
Definition Domain1D.cpp:76
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:461
double zmax() const
Get the coordinate [m] of the last (rightmost) grid point in this domain.
Definition Domain1D.h:494
virtual void fromArray(SolutionArray &arr, double *soln)
Restore the solution for this domain from a SolutionArray.
Definition Domain1D.h:380
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
Definition Domain1D.h:415
void needJacUpdate()
Set this if something has changed in the governing equations (for example, the value of a constant ha...
Definition Domain1D.cpp:113
void linkRight(Domain1D *right)
Set the right neighbor to domain 'right.'.
Definition Domain1D.h:437
virtual void _getInitialSoln(double *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition Domain1D.cpp:284
size_t index(size_t n, size_t j) const
Returns the index of the solution vector, which corresponds to component n at grid point j.
Definition Domain1D.h:335
void checkComponentArraySize(size_t nn) const
Check that an array size is at least nComponents().
Definition Domain1D.h:163
double transient_rtol(size_t n)
Transient relative tolerance of the nth component.
Definition Domain1D.h:255
int m_bw
See bandwidth()
Definition Domain1D.h:598
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:410
void locate()
Find the index of the first grid point in this domain, and the start of its variables in the global s...
Definition Domain1D.cpp:205
virtual AnyMap getMeta() const
Retrieve meta data.
Definition Domain1D.cpp:121
virtual void setupGrid(size_t n, const double *z)
called to set up initial grid, and after grid refinement
Definition Domain1D.cpp:225
An array index is out of range.
An error indicating that an unimplemented function has been called.
Container class for multiple-domain 1D problems.
Definition OneDim.h:28
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Definition refine.h:17
A container class holding arrays of state information.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180