Cantera  4.0.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(span<double> x) {}
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, span<const double> x0) {
278 auto local = x0.subspan(loc(), size());
279 std::copy(local.begin(), local.end(), m_slast.begin());
280 m_rdt = 1.0/dt;
281 }
282
283 /**
284 * Set the internally-stored reciprocal of the time step to 0.0, which is
285 * used to indicate that the problem is in steady-state mode.
286 */
288 m_rdt = 0.0;
289 }
290
291 //! True if in steady-state mode
292 bool steady() {
293 return (m_rdt == 0.0);
294 }
295
296 //! True if not in steady-state mode
297 bool transient() {
298 return (m_rdt != 0.0);
299 }
300
301 /**
302 * Set this if something has changed in the governing
303 * equations (for example, the value of a constant has been changed,
304 * so that the last-computed Jacobian is no longer valid.
305 */
306 void needJacUpdate();
307
308 //! Evaluate the residual function at point j. If j == npos,
309 //! evaluate the residual function at all points.
310 /*!
311 * This function must be implemented in classes derived from Domain1D.
312 *
313 * @param[in] j Grid point at which to update the residual
314 * @param[in] x State vector
315 * @param[out] r residual vector
316 * @param[out] mask Boolean mask indicating whether each solution
317 * component has a time derivative (1) or not (0).
318 * @param[in] rdt Reciprocal of the timestep (`rdt=0` implies steady-state.)
319 */
320 virtual void eval(size_t j, span<const double> x, span<double> r, span<int> mask,
321 double rdt=0.0) {
322 throw NotImplementedError("Domain1D::eval");
323 }
324
325 /**
326 * Returns the index of the solution vector, which corresponds to component
327 * n at grid point j.
328 *
329 * @param n component index
330 * @param j grid point index
331 */
332 size_t index(size_t n, size_t j) const {
333 return m_nv*j + n;
334 }
335
336 /**
337 * Set a single component value at a boundary.
338 * @param component Name of the component.
339 *
340 * @since New in %Cantera 3.2.
341 */
342 virtual double value(const string& component) const {
343 throw NotImplementedError("Domain1D::value",
344 "Not implemented for domain type '{}'.", domainType());
345 }
346
347 /**
348 * Set a single component value in a flow domain or at a boundary.
349 * @param component Name of the component.
350 * @param value Value of the component.
351 *
352 * @since New in %Cantera 3.2.
353 */
354 virtual void setValue(const string& component, double value) {
355 throw NotImplementedError("Domain1D::setValue",
356 "Not implemented for domain type '{}'.", domainType());
357 }
358
359 /**
360 * Retrieve component values.
361 * @param component Name of the component.
362 * @returns Vector of length nPoints() containing values at grid points.
363 *
364 * @since New in %Cantera 3.2.
365 */
366 vector<double> values(const string& component) const {
367 vector<double> data(nPoints());
368 getValues(component, data);
369 return data;
370 }
371
372 /**
373 * Retrieve component values.
374 * @param component Name of the component.
375 * @param[out] values Vector of length nPoints() containing values at grid points.
376 *
377 * @since New in %Cantera 3.2.
378 */
379 virtual void getValues(const string& component, span<double> values) const {
380 throw NotImplementedError("Domain1D::getValues",
381 "Not implemented for domain type '{}'.", domainType());
382 }
383
384 /**
385 * Specify component values.
386 * @param component Name of the component.
387 * @param[in] values Vector of length nPoints() containing values at grid points.
388 *
389 * @since New in %Cantera 3.2.
390 */
391 virtual void setValues(const string& component, span<const double> values) {
392 throw NotImplementedError("Domain1D::setValues",
393 "Not implemented for domain type '{}'.", domainType());
394 }
395
396 /**
397 * Retrieve internal work array values for a component.
398 * After calling Sim1D::eval(), this array contains the values of the residual
399 * function.
400 * @param component Name of the component.
401 * @returns Vector of length nPoints() containing residuals at grid points.
402 *
403 * @since New in %Cantera 3.2.
404 */
405 vector<double> residuals(const string& component) const {
406 vector<double> data(nPoints());
407 getResiduals(component, data);
408 return data;
409 }
410
411 /**
412 * Retrieve internal work array values for a component.
413 * After calling Sim1D::eval(), this array contains the values of the residual
414 * function.
415 * @param component Name of the component.
416 * @param[out] values Vector of length nPoints() containing residuals at grid
417 * points.
418 *
419 * @since New in %Cantera 3.2.
420 */
421 virtual void getResiduals(const string& component, span<double> values) const {
422 throw NotImplementedError("Domain1D::getResiduals",
423 "Not applicable or not implemented for domain type '{}'.", domainType());
424 }
425
426 /**
427 * Specify a profile for a component.
428 * @param component Name of the component.
429 * @param[in] pos A vector of relative positions, beginning with 0.0 at the
430 * left of the domain, and ending with 1.0 at the right of the domain.
431 * @param[in] values A vector of values corresponding to the relative position
432 * locations.
433 *
434 * Note that the vector pos and values can have lengths different than the
435 * number of grid points, but their lengths must be equal. The values at
436 * the grid points will be linearly interpolated based on the (pos,
437 * values) specification.
438 *
439 * @since New in %Cantera 3.2.
440 */
441 virtual void setProfile(const string& component,
442 span<const double> pos, span<const double> values) {
443 throw NotImplementedError("Domain1D::setProfile",
444 "Not implemented for domain type '{}'.", domainType());
445 }
446
447 /**
448 * Specify a flat profile for a component.
449 * @param component Name of the component.
450 * @param value Constant value.
451 *
452 * @since New in %Cantera 3.2.
453 */
454 virtual void setFlatProfile(const string& component, double value) {
455 throw NotImplementedError("Domain1D::setFlatProfile",
456 "Not implemented for domain type '{}'.", domainType());
457 }
458
459 //! Save the state of this domain to a SolutionArray.
460 /*!
461 * This method serves as an external interface for high-level API's; it does not
462 * provide direct access to memory.
463 * @param normalize If true, normalize concentrations (default=false)
464 *
465 * @since New in %Cantera 3.0.
466 */
467 virtual shared_ptr<SolutionArray> toArray(bool normalize=false) {
468 throw NotImplementedError("Domain1D::toArray", "Needs to be overloaded.");
469 }
470
471 //! Restore the solution for this domain from a SolutionArray.
472 /*!
473 * This method serves as an external interface for high-level API's.
474 * @param arr SolutionArray defining the state of this domain
475 * @since New in %Cantera 3.0.
476 */
477 virtual void fromArray(const shared_ptr<SolutionArray>& arr) {
478 throw NotImplementedError("Domain1D::fromArray", "Needs to be overloaded.");
479 }
480
481 /**
482 * Return a concise summary of a Domain.
483 * @see SolutionArray.info()
484 * @param keys List of components to be displayed; if empty, all components are
485 * considered.
486 * @param rows Maximum number of rendered rows.
487 * @param width Maximum width of rendered output.
488 * @since New in %Cantera 3.2
489 */
490 string info(const vector<string>& keys, int rows=10, int width=80);
491
492 /**
493 * Return a concise summary of a Domain.
494 * Skips keys input while `vector<string>` is not implemented in sourcegen.
495 * @see SolutionArray.info()
496 * @param rows Maximum number of rendered rows.
497 * @param width Maximum width of rendered output.
498 * @since New in %Cantera 3.2
499 */
500 string _info(int rows=10, int width=80) {
501 return info({}, rows, width);
502 }
503
504 //! Return thermo/kinetics/transport manager used in the domain
505 //! @since New in %Cantera 3.2.
506 shared_ptr<Solution> phase() const {
507 return m_solution;
508 }
509
510 //! Return the size of the solution vector (the product of #m_nv and #m_points).
511 size_t size() const {
512 return m_nv*m_points;
513 }
514
515 /**
516 * Find the index of the first grid point in this domain, and
517 * the start of its variables in the global solution vector.
518 */
519 void locate();
520
521 //! Location of the start of the local solution vector in the global solution vector
522 virtual size_t loc(size_t j = 0) const {
523 return m_iloc;
524 }
525
526 //! The index of the first (that is, left-most) grid point belonging to this domain.
527 size_t firstPoint() const {
528 return m_jstart;
529 }
530
531 //! The index of the last (that is, right-most) grid point belonging to this domain.
532 size_t lastPoint() const {
533 return m_jstart + m_points - 1;
534 }
535
536 /**
537 * Set the left neighbor to domain 'left.' Method 'locate' is called to
538 * update the global positions of this domain and all those to its right.
539 */
541 m_left = left;
542 locate();
543 }
544
545 //! Set the right neighbor to domain 'right.'
547 m_right = right;
548 }
549
550 //! Append domain 'right' to this one, and update all links.
553 right->linkLeft(this);
554 }
555
556 //! Return a pointer to the left neighbor.
557 Domain1D* left() const {
558 return m_left;
559 }
560
561 //! Return a pointer to the right neighbor.
562 Domain1D* right() const {
563 return m_right;
564 }
565
566 //! Value of component n at point j in the previous solution.
567 double prevSoln(size_t n, size_t j) const {
568 return m_slast[m_nv*j + n];
569 }
570
571 //! Specify an identifying tag for this domain.
572 void setID(const string& s) {
573 m_id = s;
574 }
575
576 //! Returns the identifying tag for this domain.
577 string id() const {
578 if (m_id != "") {
579 return m_id;
580 } else {
581 return fmt::format("domain {}", m_index);
582 }
583 }
584
585 //! Print the solution.
586 //! @param x Pointer to the local portion of the system state vector
587 virtual void show(span<const double> x);
588
589 //! Get the coordinate [m] of the point with local index `jlocal`
590 double z(size_t jlocal) const {
591 return m_z[jlocal];
592 }
593
594 //! Get the coordinate [m] of the first (leftmost) grid point in this domain
595 double zmin() const {
596 return m_z[0];
597 }
598
599 //! Get the coordinate [m] of the last (rightmost) grid point in this domain
600 double zmax() const {
601 return m_z[m_points - 1];
602 }
603
604 //! Access the array of grid coordinates [m]
605 span<double> grid() {
606 return m_z;
607 }
608
609 //! Access the array of grid coordinates [m]
610 span<const double> grid() const {
611 return m_z;
612 }
613
614 //! Set up initial grid.
615 //! @since New in %Cantera 3.2.
616 //! called to set up initial grid, and after grid refinement
617 virtual void setupGrid(span<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(span<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(span<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
virtual void setValues(const string &component, span< const double > values)
Specify component values.
Definition Domain1D.h:391
void setTransientTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for time-stepping mode.
Definition Domain1D.cpp:93
size_t lastPoint() const
The index of the last (that is, right-most) grid point belonging to this domain.
Definition Domain1D.h:532
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
virtual void _getInitialSoln(span< double > x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition Domain1D.cpp:268
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
void initTimeInteg(double dt, span< const double > x0)
Performs the setup required before starting a time-stepping solution.
Definition Domain1D.h:277
bool transient()
True if not in steady-state mode.
Definition Domain1D.h:297
void setComponentName(size_t n, const string &name)
Set the name of the component n to name.
Definition Domain1D.h:155
virtual void setupGrid(span< const double > z)
Set up initial grid.
Definition Domain1D.cpp:207
virtual void resetBadValues(span< double > x)
When called, this function should reset "bad" values in the state vector such as negative species con...
Definition Domain1D.h:127
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:214
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:511
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:500
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
size_t m_index
Left-to-right location of this domain.
Definition Domain1D.h:689
Domain1D * left() const
Return a pointer to the left neighbor.
Definition Domain1D.h:557
vector< double > residuals(const string &component) const
Retrieve internal work array values for a component.
Definition Domain1D.h:405
string id() const
Returns the identifying tag for this domain.
Definition Domain1D.h:577
double zmin() const
Get the coordinate [m] of the first (leftmost) grid point in this domain.
Definition Domain1D.h:595
span< double > grid()
Access the array of grid coordinates [m].
Definition Domain1D.h:605
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:506
size_t m_nv
Number of solution components.
Definition Domain1D.h:675
virtual void eval(size_t j, span< const double > x, span< double > r, span< int > mask, double rdt=0.0)
Evaluate the residual function at point j.
Definition Domain1D.h:320
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:540
span< const double > grid() const
Access the array of grid coordinates [m].
Definition Domain1D.h:610
vector< double > values(const string &component) const
Retrieve component values.
Definition Domain1D.h:366
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:590
virtual void setValue(const string &component, double value)
Set a single component value in a flow domain or at a boundary.
Definition Domain1D.h:354
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:562
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:342
virtual void fromArray(const shared_ptr< SolutionArray > &arr)
Restore the solution for this domain from a SolutionArray.
Definition Domain1D.h:477
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
virtual void getResiduals(const string &component, span< double > values) const
Retrieve internal work array values for a component.
Definition Domain1D.h:421
double transient_atol(size_t n)
Transient absolute tolerance of the nth component.
Definition Domain1D.h:241
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:572
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 OneDim & container() const
The container holding this domain.
Definition Domain1D.h:80
size_t m_points
Number of grid points.
Definition Domain1D.h:676
bool steady()
True if in steady-state mode.
Definition Domain1D.h:292
virtual void show(span< const double > x)
Print the solution.
Definition Domain1D.cpp:224
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 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
void setData(shared_ptr< vector< double > > &data)
Set shared data pointer.
Definition Domain1D.h:659
virtual void setProfile(const string &component, span< const double > pos, span< const double > values)
Specify a profile for a component.
Definition Domain1D.h:441
void append(Domain1D *right)
Append domain 'right' to this one, and update all links.
Definition Domain1D.h:551
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:287
virtual double initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
Definition Domain1D.cpp:277
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:567
double zmax() const
Get the coordinate [m] of the last (rightmost) grid point in this domain.
Definition Domain1D.h:600
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
Definition Domain1D.h:527
virtual shared_ptr< SolutionArray > toArray(bool normalize=false)
Save the state of this domain to a SolutionArray.
Definition Domain1D.h:467
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:546
virtual void getValues(const string &component, span< double > values) const
Retrieve component values.
Definition Domain1D.h:379
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:332
vector< double > getRefineCriteria()
Get the grid refinement criteria.
Definition Domain1D.cpp:263
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:522
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 void _finalize(span< const double > x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
Definition Domain1D.h:646
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:258
virtual void setFlatProfile(const string &component, double value)
Specify a flat profile for a component.
Definition Domain1D.h:454
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:183