Cantera  3.3.0a1
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{
30protected:
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 explicit Domain1D(size_t nv=1, size_t points=1, double time=0.0);
38
39public:
40 virtual ~Domain1D();
41 Domain1D(const Domain1D&) = delete;
42 Domain1D& operator=(const Domain1D&) = delete;
43
44 //! Domain type flag.
45 //! @since Starting in %Cantera 3.1, the return type is a `string`.
46 virtual string domainType() const { return "domain"; }
47
48 //! The left-to-right location of this domain.
49 size_t domainIndex() {
50 return m_index;
51 }
52
53 //! True if the domain is a connector domain.
54 virtual bool isConnector() {
55 return false;
56 }
57
58 //! Set transport model by name.
59 //! @param model String specifying model name.
60 //! @since New in %Cantera 3.2.
61 virtual void setTransportModel(const string& model) {
62 throw NotImplementedError("Domain1D::setTransportModel");
63 }
64
65protected:
66 //! Update transport model to existing instance
67 //! @since New in %Cantera 3.2.
68 virtual void _setKinetics(shared_ptr<Kinetics> kin) {
69 throw NotImplementedError("Domain1D::_setKinetics");
70 }
71
72 //! Update transport model to existing instance
73 //! @since New in %Cantera 3.2.
74 virtual void _setTransport(shared_ptr<Transport> trans) {
75 throw NotImplementedError("Domain1D::_setTransport");
76 }
77
78public:
79 //! The container holding this domain.
80 const OneDim& container() const {
81 return *m_container;
82 }
83
84 //! Specify the container object for this domain, and the position of this
85 //! domain in the list.
86 void setContainer(OneDim* c, size_t index) {
87 m_container = c;
88 m_index = index;
89 }
90
91 //! Set the Jacobian bandwidth. See the discussion of method bandwidth().
92 void setBandwidth(int bw = -1) {
93 m_bw = bw;
94 }
95
96 //! Set the Jacobian bandwidth for this domain.
97 /**
98 * When class OneDim computes the bandwidth of the overall multi-domain
99 * problem (in OneDim::resize()), it calls this method for the bandwidth
100 * of each domain. If setBandwidth has not been called, then a negative
101 * bandwidth is returned, in which case OneDim assumes that this domain is
102 * dense -- that is, at each point, all components depend on the value of
103 * all other components at that point. In this case, the bandwidth is bw =
104 * 2*nComponents() - 1. However, if this domain contains some components
105 * that are uncoupled from other components at the same point, then this
106 * default bandwidth may greatly overestimate the true bandwidth, with a
107 * substantial penalty in performance. For such domains, use method
108 * setBandwidth to specify the bandwidth before passing this domain to the
109 * Sim1D or OneDim constructor.
110 */
111 size_t bandwidth() {
112 return m_bw;
113 }
114
115 /**
116 * Initialize. This method is called by OneDim::init() for each domain once
117 * at the beginning of a simulation. Base class method does nothing, but may
118 * be overloaded.
119 */
120 virtual void init() { }
121
122 /**
123 * When called, this function should reset "bad" values in the state vector
124 * such as negative species concentrations. This function may be called
125 * after a failed solution attempt.
126 */
127 virtual void resetBadValues(double* xg) {}
128
129 /**
130 * Resize the domain to have nv components and np grid points. This method
131 * is virtual so that subclasses can perform other actions required to
132 * resize the domain.
133 */
134 virtual void resize(size_t nv, size_t np);
135
136 //! Return a reference to the grid refiner.
138 return *m_refiner;
139 }
140
141 //! Number of components at each grid point.
142 size_t nComponents() const {
143 return m_nv;
144 }
145
146 //! Number of grid points in this domain.
147 size_t nPoints() const {
148 return m_points;
149 }
150
151 //! Name of component `n`. May be overloaded.
152 virtual string componentName(size_t n) const;
153
154 //! Set the name of the component `n` to `name`.
155 void setComponentName(size_t n, const string& name) {
156 m_name[n] = name;
157 }
158
159 /**
160 * Index of component with name `name`.
161 * @param name name of component
162 * @param checkAlias if `true` (default), check alias mapping
163 */
164 virtual size_t componentIndex(const string& name, bool checkAlias=true) const;
165
166 /**
167 * Check whether the Domain contains a component.
168 * @param name name of component
169 * @param checkAlias if `true` (default), check alias mapping
170 *
171 * @since New in %Cantera 3.2.
172 */
173 virtual bool hasComponent(const string& name, bool checkAlias=true) const;
174
175 /**
176 * Update state at given location to state of associated Solution object.
177 */
178 virtual void updateState(size_t loc) {
179 throw NotImplementedError("Domain1D::updateState",
180 "Not implemented for domain type '{}'.", domainType());
181 }
182
183 /**
184 * Set the upper and lower bounds for a solution component, n.
185 *
186 * @param n solution component index
187 * @param lower lower bound on component n
188 * @param upper upper bound on component n
189 */
190 void setBounds(size_t n, double lower, double upper) {
191 m_min[n] = lower;
192 m_max[n] = upper;
193 }
194
195 //! Set tolerances for time-stepping mode
196 /*!
197 * @param rtol Relative tolerance
198 * @param atol Absolute tolerance
199 * @param n component index these tolerances apply to. If set to -1 (the
200 * default), these tolerances will be applied to all solution
201 * components.
202 */
203 void setTransientTolerances(double rtol, double atol, size_t n=npos);
204
205 //! Set tolerances for steady-state mode
206 /*!
207 * @param rtol Relative tolerance
208 * @param atol Absolute tolerance
209 * @param n component index these tolerances apply to. If set to -1 (the
210 * default), these tolerances will be applied to all solution
211 * components.
212 */
213 void setSteadyTolerances(double rtol, double atol, size_t n=npos);
214
215 //! Relative tolerance of the nth component.
216 double rtol(size_t n) {
217 return (m_rdt == 0.0 ? m_rtol_ss[n] : m_rtol_ts[n]);
218 }
219
220 //! Absolute tolerance of the nth component.
221 double atol(size_t n) {
222 return (m_rdt == 0.0 ? m_atol_ss[n] : m_atol_ts[n]);
223 }
224
225 //! Steady relative tolerance of the nth component
226 double steady_rtol(size_t n) {
227 return m_rtol_ss[n];
228 }
229
230 //! Steady absolute tolerance of the nth component
231 double steady_atol(size_t n) {
232 return m_atol_ss[n];
233 }
234
235 //! Transient relative tolerance of the nth component
236 double transient_rtol(size_t n) {
237 return m_rtol_ts[n];
238 }
239
240 //! Transient absolute tolerance of the nth component
241 double transient_atol(size_t n) {
242 return m_atol_ts[n];
243 }
244
245 //! Upper bound on the nth component.
246 double upperBound(size_t n) const {
247 return m_max[n];
248 }
249
250 //! Lower bound on the nth component
251 double lowerBound(size_t n) const {
252 return m_min[n];
253 }
254
255 /**
256 * Set grid refinement criteria. @see Refiner::setCriteria.
257 * @since New in %Cantera 3.2
258 */
259 void setRefineCriteria(double ratio = 10.0,
260 double slope = 0.8, double curve = 0.8,
261 double prune = -0.1);
262
263 /**
264 * Get the grid refinement criteria. @see Refiner::getCriteria
265 * @since New in %Cantera 3.2
266 */
267 vector<double> getRefineCriteria();
268
269 /**
270 * Performs the setup required before starting a time-stepping solution.
271 * Stores the solution provided in `x0` to the internal storage, and sets
272 * the reciprocal of the time step to `1/dt`.
273 *
274 * @param[in] dt Time step
275 * @param[in] x0 Array to store the solution at the last time step
276 */
277 void initTimeInteg(double dt, const double* x0) {
278 std::copy(x0 + loc(), x0 + loc() + size(), m_slast.begin());
279 m_rdt = 1.0/dt;
280 }
281
282 /**
283 * Set the internally-stored reciprocal of the time step to 0.0, which is
284 * used to indicate that the problem is in steady-state mode.
285 */
287 m_rdt = 0.0;
288 }
289
290 //! True if in steady-state mode
291 bool steady() {
292 return (m_rdt == 0.0);
293 }
294
295 //! True if not in steady-state mode
296 bool transient() {
297 return (m_rdt != 0.0);
298 }
299
300 /**
301 * Set this if something has changed in the governing
302 * equations (for example, the value of a constant has been changed,
303 * so that the last-computed Jacobian is no longer valid.
304 */
305 void needJacUpdate();
306
307 //! Evaluate the residual function at point j. If j == npos,
308 //! evaluate the residual function at all points.
309 /*!
310 * This function must be implemented in classes derived from Domain1D.
311 *
312 * @param[in] j Grid point at which to update the residual
313 * @param[in] x State vector
314 * @param[out] r residual vector
315 * @param[out] mask Boolean mask indicating whether each solution
316 * component has a time derivative (1) or not (0).
317 * @param[in] rdt Reciprocal of the timestep (`rdt=0` implies steady-state.)
318 */
319 virtual void eval(size_t j, double* x, double* r, integer* mask, double rdt=0.0) {
320 throw NotImplementedError("Domain1D::eval");
321 }
322
323 /**
324 * Returns the index of the solution vector, which corresponds to component
325 * n at grid point j.
326 *
327 * @param n component index
328 * @param j grid point index
329 */
330 size_t index(size_t n, size_t j) const {
331 return m_nv*j + n;
332 }
333
334 /**
335 * Set a single component value at a boundary.
336 * @param component Name of the component.
337 *
338 * @since New in %Cantera 3.2.
339 */
340 virtual double value(const string& component) const {
341 throw NotImplementedError("Domain1D::value",
342 "Not implemented for domain type '{}'.", domainType());
343 }
344
345 /**
346 * Set a single component value in a flow domain or at a boundary.
347 * @param component Name of the component.
348 * @param value Value of the component.
349 *
350 * @since New in %Cantera 3.2.
351 */
352 virtual void setValue(const string& component, double value) {
353 throw NotImplementedError("Domain1D::setValue",
354 "Not implemented for domain type '{}'.", domainType());
355 }
356
357 /**
358 * Retrieve component values.
359 * @param component Name of the component.
360 * @returns Vector of length nPoints() containing values at grid points.
361 *
362 * @since New in %Cantera 3.2.
363 */
364 vector<double> values(const string& component) const {
365 vector<double> data(nPoints());
366 getValues(component, data);
367 return data;
368 }
369
370 /**
371 * Retrieve component values.
372 * @param component Name of the component.
373 * @param[out] values Vector of length nPoints() containing values at grid points.
374 *
375 * @since New in %Cantera 3.2.
376 */
377 virtual void getValues(const string& component, vector<double>& values) const {
378 throw NotImplementedError("Domain1D::getValues",
379 "Not implemented for domain type '{}'.", domainType());
380 }
381
382 /**
383 * Specify component values.
384 * @param component Name of the component.
385 * @param[in] values Vector of length nPoints() containing values at grid points.
386 *
387 * @since New in %Cantera 3.2.
388 */
389 virtual void setValues(const string& component, const vector<double>& values) {
390 throw NotImplementedError("Domain1D::setValues",
391 "Not implemented for domain type '{}'.", domainType());
392 }
393
394 /**
395 * Retrieve internal work array values for a component.
396 * After calling Sim1D::eval(), this array contains the values of the residual
397 * function.
398 * @param component Name of the component.
399 * @returns Vector of length nPoints() containing residuals at grid points.
400 *
401 * @since New in %Cantera 3.2.
402 */
403 vector<double> residuals(const string& component) const {
404 vector<double> data(nPoints());
405 getResiduals(component, data);
406 return data;
407 }
408
409 /**
410 * Retrieve internal work array values for a component.
411 * After calling Sim1D::eval(), this array contains the values of the residual
412 * function.
413 * @param component Name of the component.
414 * @param[out] values Vector of length nPoints() containing residuals at grid
415 * points.
416 *
417 * @since New in %Cantera 3.2.
418 */
419 virtual void getResiduals(const string& component, vector<double>& values) const {
420 throw NotImplementedError("Domain1D::getResiduals",
421 "Not applicable or not implemented for domain type '{}'.", domainType());
422 }
423
424 /**
425 * Specify a profile for a component.
426 * @param component Name of the component.
427 * @param[in] pos A vector of relative positions, beginning with 0.0 at the
428 * left of the domain, and ending with 1.0 at the right of the domain.
429 * @param[in] values A vector of values corresponding to the relative position
430 * locations.
431 *
432 * Note that the vector pos and values can have lengths different than the
433 * number of grid points, but their lengths must be equal. The values at
434 * the grid points will be linearly interpolated based on the (pos,
435 * values) specification.
436 *
437 * @since New in %Cantera 3.2.
438 */
439 virtual void setProfile(const string& component,
440 const vector<double>& pos, const vector<double>& values) {
441 throw NotImplementedError("Domain1D::setProfile",
442 "Not implemented for domain type '{}'.", domainType());
443 }
444
445 /**
446 * Specify a flat profile for a component.
447 * @param component Name of the component.
448 * @param value Constant value.
449 *
450 * @since New in %Cantera 3.2.
451 */
452 virtual void setFlatProfile(const string& component, double value) {
453 throw NotImplementedError("Domain1D::setFlatProfile",
454 "Not implemented for domain type '{}'.", domainType());
455 }
456
457 //! Save the state of this domain to a SolutionArray.
458 /*!
459 * This method serves as an external interface for high-level API's; it does not
460 * provide direct access to memory.
461 * @param normalize If true, normalize concentrations (default=false)
462 *
463 * @since New in %Cantera 3.0.
464 */
465 virtual shared_ptr<SolutionArray> toArray(bool normalize=false) {
466 throw NotImplementedError("Domain1D::toArray", "Needs to be overloaded.");
467 }
468
469 //! Restore the solution for this domain from a SolutionArray.
470 /*!
471 * This method serves as an external interface for high-level API's.
472 * @param arr SolutionArray defining the state of this domain
473 * @since New in %Cantera 3.0.
474 */
475 virtual void fromArray(const shared_ptr<SolutionArray>& arr) {
476 throw NotImplementedError("Domain1D::fromArray", "Needs to be overloaded.");
477 }
478
479 /**
480 * Return a concise summary of a Domain.
481 * @see SolutionArray.info()
482 * @param keys List of components to be displayed; if empty, all components are
483 * considered.
484 * @param rows Maximum number of rendered rows.
485 * @param width Maximum width of rendered output.
486 * @since New in %Cantera 3.2
487 */
488 string info(const vector<string>& keys, int rows=10, int width=80);
489
490 /**
491 * Return a concise summary of a Domain.
492 * Skips keys input while `vector<string>` is not implemented in sourcegen.
493 * @see SolutionArray.info()
494 * @param rows Maximum number of rendered rows.
495 * @param width Maximum width of rendered output.
496 * @since New in %Cantera 3.2
497 */
498 string _info(int rows=10, int width=80) {
499 return info({}, rows, width);
500 }
501
502 //! Return thermo/kinetics/transport manager used in the domain
503 //! @since New in %Cantera 3.2.
504 shared_ptr<Solution> phase() const {
505 return m_solution;
506 }
507
508 //! Return the size of the solution vector (the product of #m_nv and #m_points).
509 size_t size() const {
510 return m_nv*m_points;
511 }
512
513 /**
514 * Find the index of the first grid point in this domain, and
515 * the start of its variables in the global solution vector.
516 */
517 void locate();
518
519 //! Location of the start of the local solution vector in the global solution vector
520 virtual size_t loc(size_t j = 0) const {
521 return m_iloc;
522 }
523
524 //! The index of the first (that is, left-most) grid point belonging to this domain.
525 size_t firstPoint() const {
526 return m_jstart;
527 }
528
529 //! The index of the last (that is, right-most) grid point belonging to this domain.
530 size_t lastPoint() const {
531 return m_jstart + m_points - 1;
532 }
533
534 /**
535 * Set the left neighbor to domain 'left.' Method 'locate' is called to
536 * update the global positions of this domain and all those to its right.
537 */
539 m_left = left;
540 locate();
541 }
542
543 //! Set the right neighbor to domain 'right.'
545 m_right = right;
546 }
547
548 //! Append domain 'right' to this one, and update all links.
551 right->linkLeft(this);
552 }
553
554 //! Return a pointer to the left neighbor.
555 Domain1D* left() const {
556 return m_left;
557 }
558
559 //! Return a pointer to the right neighbor.
560 Domain1D* right() const {
561 return m_right;
562 }
563
564 //! Value of component n at point j in the previous solution.
565 double prevSoln(size_t n, size_t j) const {
566 return m_slast[m_nv*j + n];
567 }
568
569 //! Specify an identifying tag for this domain.
570 void setID(const string& s) {
571 m_id = s;
572 }
573
574 //! Returns the identifying tag for this domain.
575 string id() const {
576 if (m_id != "") {
577 return m_id;
578 } else {
579 return fmt::format("domain {}", m_index);
580 }
581 }
582
583 //! Print the solution.
584 //! @param x Pointer to the local portion of the system state vector
585 virtual void show(const double* x);
586
587 //! Get the coordinate [m] of the point with local index `jlocal`
588 double z(size_t jlocal) const {
589 return m_z[jlocal];
590 }
591
592 //! Get the coordinate [m] of the first (leftmost) grid point in this domain
593 double zmin() const {
594 return m_z[0];
595 }
596
597 //! Get the coordinate [m] of the last (rightmost) grid point in this domain
598 double zmax() const {
599 return m_z[m_points - 1];
600 }
601
602 //! Access the array of grid coordinates [m]
603 vector<double>& grid() {
604 return m_z;
605 }
606
607 //! Access the array of grid coordinates [m]
608 const vector<double>& grid() const {
609 return m_z;
610 }
611
612 //! Set up initial grid.
613 //! @since New in %Cantera 3.2.
614 void setupGrid(const vector<double>& grid);
615
616 //! called to set up initial grid, and after grid refinement
617 virtual void setupGrid(size_t n, const double* z);
618
619 //! Set up uniform grid.
620 //! @param points Number of grid points
621 //! @param length Length of domain
622 //! @param start Start position of domain (default=0.)
623 //! @since New in %Cantera 3.2.
624 void setupUniformGrid(size_t points, double length, double start=0.);
625
626 /**
627 * Writes some or all initial solution values into the global solution
628 * array, beginning at the location pointed to by x. This method is called
629 * by the Sim1D constructor, and allows default values or ones that have
630 * been set locally prior to installing this domain into the container to be
631 * written to the global solution vector.
632 */
633 virtual void _getInitialSoln(double* x);
634
635 //! Initial value of solution component @e n at grid point @e j.
636 virtual double initialValue(size_t n, size_t j);
637
638 /**
639 * In some cases, a domain may need to set parameters that depend on the
640 * initial solution estimate. In such cases, the parameters may be set in
641 * method _finalize. This method is called just before the Newton solver is
642 * called, and the x array is guaranteed to be the local solution vector for
643 * this domain that will be used as the initial guess. If no such parameters
644 * need to be set, then method _finalize does not need to be overloaded.
645 */
646 virtual void _finalize(const double* x) {}
647
648 /**
649 * In some cases, for computational efficiency some properties (such as
650 * transport coefficients) may not be updated during Jacobian evaluations.
651 * Set this to `true` to force these properties to be updated even while
652 * calculating Jacobian elements.
653 */
654 void forceFullUpdate(bool update) {
655 m_force_full_update = update;
656 }
657
658 //! Set shared data pointer
659 void setData(shared_ptr<vector<double>>& data) {
660 m_state = data;
661 }
662
663protected:
664 //! Retrieve meta data
665 virtual AnyMap getMeta() const;
666
667 //! Retrieve meta data
668 virtual void setMeta(const AnyMap& meta);
669
670 double m_press = -1.0; //!< pressure [Pa]
671
672 shared_ptr<vector<double>> m_state; //!< data pointer shared from OneDim
673
674 double m_rdt = 0.0; //!< Reciprocal of the time step
675 size_t m_nv = 0; //!< Number of solution components
676 size_t m_points; //!< Number of grid points
677 vector<double> m_slast; //!< Solution vector at the last time step
678 vector<double> m_max; //!< Upper bounds on solution components
679 vector<double> m_min; //!< Lower bounds on solution components
680 vector<double> m_rtol_ss; //!< Relative tolerances for steady mode
681 vector<double> m_rtol_ts; //!< Relative tolerances for transient mode
682 vector<double> m_atol_ss; //!< Absolute tolerances for steady mode
683 vector<double> m_atol_ts; //!< Absolute tolerances for transient mode
684 vector<double> m_z; //!< 1D spatial grid coordinates
685
686 //! Parent OneDim simulation containing this and adjacent domains
687 OneDim* m_container = nullptr;
688
689 size_t m_index; //!< Left-to-right location of this domain
690
691 //! Starting location within the solution vector for unknowns that
692 //! correspond to this domain
693 /*!
694 * Remember there may be multiple domains associated with this problem
695 */
696 size_t m_iloc = 0;
697
698 //! Index of the first point in this domain in the global point list.
699 //! @see firstPoint(), lastPoint()
700 size_t m_jstart = 0;
701
702 Domain1D* m_left = nullptr; //!< Pointer to the domain to the left
703 Domain1D* m_right = nullptr; //!< Pointer to the domain to the right
704
705 //! Identity tag for the domain
706 string m_id;
707 unique_ptr<Refiner> m_refiner; //!< Refiner object used for placing grid points
708 vector<string> m_name; //!< Names of solution components
709 int m_bw = -1; //!< See bandwidth()
710 bool m_force_full_update = false; //!< see forceFullUpdate()
711
712 //! Composite thermo/kinetics/transport handler
713 shared_ptr<Solution> m_solution;
714};
715}
716
717#endif
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
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:93
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:127
size_t lastPoint() const
The index of the last (that is, right-most) grid point belonging to this domain.
Definition Domain1D.h:530
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain.
Definition Domain1D.h:696
size_t domainIndex()
The left-to-right location of this domain.
Definition Domain1D.h:49
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
Definition Domain1D.h:713
Domain1D * m_left
Pointer to the domain to the left.
Definition Domain1D.h:702
OneDim * m_container
Parent OneDim simulation containing this and adjacent domains.
Definition Domain1D.h:687
bool transient()
True if not in steady-state mode.
Definition Domain1D.h:296
void setComponentName(size_t n, const string &name)
Set the name of the component n to name.
Definition Domain1D.h:155
size_t nComponents() const
Number of components at each grid point.
Definition Domain1D.h:142
size_t bandwidth()
Set the Jacobian bandwidth for this domain.
Definition Domain1D.h:111
double rtol(size_t n)
Relative tolerance of the nth component.
Definition Domain1D.h:216
vector< double > m_atol_ss
Absolute tolerances for steady mode.
Definition Domain1D.h:682
void setupUniformGrid(size_t points, double length, double start=0.)
Set up uniform grid.
Definition Domain1D.cpp:222
vector< double > m_rtol_ts
Relative tolerances for transient mode.
Definition Domain1D.h:681
size_t size() const
Return the size of the solution vector (the product of m_nv and m_points).
Definition Domain1D.h:509
vector< double > m_atol_ts
Absolute tolerances for transient mode.
Definition Domain1D.h:683
virtual void updateState(size_t loc)
Update state at given location to state of associated Solution object.
Definition Domain1D.h:178
virtual bool isConnector()
True if the domain is a connector domain.
Definition Domain1D.h:54
string _info(int rows=10, int width=80)
Return a concise summary of a Domain.
Definition Domain1D.h:498
virtual void _setKinetics(shared_ptr< Kinetics > kin)
Update transport model to existing instance.
Definition Domain1D.h:68
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
Definition Domain1D.cpp:155
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:646
size_t m_index
Left-to-right location of this domain.
Definition Domain1D.h:689
void setupGrid(const vector< double > &grid)
Set up initial grid.
Definition Domain1D.cpp:207
Domain1D * left() const
Return a pointer to the left neighbor.
Definition Domain1D.h:555
vector< double > residuals(const string &component) const
Retrieve internal work array values for a component.
Definition Domain1D.h:403
string id() const
Returns the identifying tag for this domain.
Definition Domain1D.h:575
vector< double > & grid()
Access the array of grid coordinates [m].
Definition Domain1D.h:603
double zmin() const
Get the coordinate [m] of the first (leftmost) grid point in this domain.
Definition Domain1D.h:593
size_t m_jstart
Index of the first point in this domain in the global point list.
Definition Domain1D.h:700
shared_ptr< Solution > phase() const
Return thermo/kinetics/transport manager used in the domain.
Definition Domain1D.h:504
size_t m_nv
Number of solution components.
Definition Domain1D.h:675
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:86
size_t nPoints() const
Number of grid points in this domain.
Definition Domain1D.h:147
vector< string > m_name
Names of solution components.
Definition Domain1D.h:708
double m_rdt
Reciprocal of the time step.
Definition Domain1D.h:674
virtual string domainType() const
Domain type flag.
Definition Domain1D.h:46
bool m_force_full_update
see forceFullUpdate()
Definition Domain1D.h:710
string info(const vector< string > &keys, int rows=10, int width=80)
Return a concise summary of a Domain.
Definition Domain1D.cpp:31
double lowerBound(size_t n) const
Lower bound on the nth component.
Definition Domain1D.h:251
virtual void setTransportModel(const string &model)
Set transport model by name.
Definition Domain1D.h:61
virtual size_t componentIndex(const string &name, bool checkAlias=true) const
Index of component with name name.
Definition Domain1D.cpp:71
shared_ptr< vector< double > > m_state
data pointer shared from OneDim
Definition Domain1D.h:672
void linkLeft(Domain1D *left)
Set the left neighbor to domain 'left.
Definition Domain1D.h:538
vector< double > values(const string &component) const
Retrieve component values.
Definition Domain1D.h:364
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
Definition Domain1D.cpp:36
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:588
virtual void setValue(const string &component, double value)
Set a single component value in a flow domain or at a boundary.
Definition Domain1D.h:352
double upperBound(size_t n) const
Upper bound on the nth component.
Definition Domain1D.h:246
Refiner & refiner()
Return a reference to the grid refiner.
Definition Domain1D.h:137
Domain1D * right() const
Return a pointer to the right neighbor.
Definition Domain1D.h:560
virtual void show(const double *x)
Print the solution.
Definition Domain1D.cpp:232
vector< double > m_rtol_ss
Relative tolerances for steady mode.
Definition Domain1D.h:680
double m_press
pressure [Pa]
Definition Domain1D.h:670
vector< double > m_slast
Solution vector at the last time step.
Definition Domain1D.h:677
virtual double value(const string &component) const
Set a single component value at a boundary.
Definition Domain1D.h:340
virtual void fromArray(const shared_ptr< SolutionArray > &arr)
Restore the solution for this domain from a SolutionArray.
Definition Domain1D.h:475
Domain1D * m_right
Pointer to the domain to the right.
Definition Domain1D.h:703
double steady_atol(size_t n)
Steady absolute tolerance of the nth component.
Definition Domain1D.h:231
void setSteadyTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for steady-state mode.
Definition Domain1D.cpp:106
virtual string componentName(size_t n) const
Name of component n. May be overloaded.
Definition Domain1D.cpp:59
double transient_atol(size_t n)
Transient absolute tolerance of the nth component.
Definition Domain1D.h:241
virtual void getValues(const string &component, vector< double > &values) const
Retrieve component values.
Definition Domain1D.h:377
virtual void _setTransport(shared_ptr< Transport > trans)
Update transport model to existing instance.
Definition Domain1D.h:74
virtual void init()
Initialize.
Definition Domain1D.h:120
double atol(size_t n)
Absolute tolerance of the nth component.
Definition Domain1D.h:221
void setID(const string &s)
Specify an identifying tag for this domain.
Definition Domain1D.h:570
vector< double > m_z
1D spatial grid coordinates
Definition Domain1D.h:684
void forceFullUpdate(bool update)
In some cases, for computational efficiency some properties (such as transport coefficients) may not ...
Definition Domain1D.h:654
const vector< double > & grid() const
Access the array of grid coordinates [m].
Definition Domain1D.h:608
const OneDim & container() const
The container holding this domain.
Definition Domain1D.h:80
virtual void setValues(const string &component, const vector< double > &values)
Specify component values.
Definition Domain1D.h:389
size_t m_points
Number of grid points.
Definition Domain1D.h:676
bool steady()
True if in steady-state mode.
Definition Domain1D.h:291
void setBandwidth(int bw=-1)
Set the Jacobian bandwidth. See the discussion of method bandwidth().
Definition Domain1D.h:92
double steady_rtol(size_t n)
Steady relative tolerance of the nth component.
Definition Domain1D.h:226
string m_id
Identity tag for the domain.
Definition Domain1D.h:706
vector< double > m_max
Upper bounds on solution components.
Definition Domain1D.h:678
unique_ptr< Refiner > m_refiner
Refiner object used for placing grid points.
Definition Domain1D.h:707
void initTimeInteg(double dt, const double *x0)
Performs the setup required before starting a time-stepping solution.
Definition Domain1D.h:277
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
Definition Domain1D.h:190
vector< double > m_min
Lower bounds on solution components.
Definition Domain1D.h:679
virtual void setProfile(const string &component, const vector< double > &pos, const vector< double > &values)
Specify a profile for a component.
Definition Domain1D.h:439
void setData(shared_ptr< vector< double > > &data)
Set shared data pointer.
Definition Domain1D.h:659
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:319
void append(Domain1D *right)
Append domain 'right' to this one, and update all links.
Definition Domain1D.h:549
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:286
virtual double initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
Definition Domain1D.cpp:285
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:565
double zmax() const
Get the coordinate [m] of the last (rightmost) grid point in this domain.
Definition Domain1D.h:598
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
Definition Domain1D.h:525
virtual shared_ptr< SolutionArray > toArray(bool normalize=false)
Save the state of this domain to a SolutionArray.
Definition Domain1D.h:465
void needJacUpdate()
Set this if something has changed in the governing equations (for example, the value of a constant ha...
Definition Domain1D.cpp:119
void linkRight(Domain1D *right)
Set the right neighbor to domain 'right.'.
Definition Domain1D.h:544
virtual void _getInitialSoln(double *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition Domain1D.cpp:276
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:330
vector< double > getRefineCriteria()
Get the grid refinement criteria.
Definition Domain1D.cpp:271
double transient_rtol(size_t n)
Transient relative tolerance of the nth component.
Definition Domain1D.h:236
int m_bw
See bandwidth()
Definition Domain1D.h:709
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:520
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:187
virtual AnyMap getMeta() const
Retrieve meta data.
Definition Domain1D.cpp:127
virtual bool hasComponent(const string &name, bool checkAlias=true) const
Check whether the Domain contains a component.
Definition Domain1D.cpp:82
void setRefineCriteria(double ratio=10.0, double slope=0.8, double curve=0.8, double prune=-0.1)
Set grid refinement criteria.
Definition Domain1D.cpp:266
virtual void setFlatProfile(const string &component, double value)
Specify a flat profile for a component.
Definition Domain1D.h:452
virtual void getResiduals(const string &component, vector< double > &values) const
Retrieve internal work array values for a component.
Definition Domain1D.h:419
An error indicating that an unimplemented function has been called.
Container class for multiple-domain 1D problems.
Definition OneDim.h:26
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Definition refine.h:17
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