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