17 Domain1D::Domain1D(
size_t nv,
size_t points,
double time) :
28 m_force_full_update(false)
37 if (nv != m_nv || !m_refiner) {
39 m_refiner.reset(
new Refiner(*
this));
42 m_name.resize(m_nv,
"");
43 m_max.resize(m_nv, 0.0);
44 m_min.resize(m_nv, 0.0);
46 m_rtol_ss.resize(m_nv, 1.0e-4);
47 m_atol_ss.resize(m_nv, 1.0e-9);
48 m_rtol_ts.resize(m_nv, 1.0e-4);
49 m_atol_ts.resize(m_nv, 1.0e-11);
52 m_slast.resize(m_nv * m_points, 0.0);
58 if (m_name[n] !=
"") {
61 return fmt::format(
"component {}", n);
73 "no component named "+name);
79 for (n = 0; n < m_nv; n++) {
92 for (n = 0; n < m_nv; n++) {
126 vector<XML_Node*> nodes = dom.
getChildren(
"floatArray");
127 for (
size_t i = 0; i < nodes.size(); i++) {
128 string title = nodes[i]->attrib(
"title");
132 warn_user(
"Domain1D::restore",
"Received an array of length "
133 "{} when one of length {} was expected. Tolerances for "
134 "individual species may not be preserved.",
141 if (!values.empty()) {
142 values.resize(
nComponents(), values[values.size()-1]);
149 if (title ==
"abstol_transient") {
151 }
else if (title ==
"reltol_transient") {
153 }
else if (title ==
"abstol_steady") {
155 }
else if (title ==
"reltol_steady") {
159 "Got an unexpected array, '" + title +
"'");
188 for (
size_t j = 0; j < m_points; j++) {
197 for (
size_t i = 0; i < nn; i++) {
198 writeline(
'-', 79,
false,
true);
200 for (
size_t n = 0; n < 5; n++) {
203 writeline(
'-', 79,
false,
true);
204 for (
size_t j = 0; j < m_points; j++) {
206 for (
size_t n = 0; n < 5; n++) {
207 double v = value(x, i*5+n, j);
213 size_t nrem = m_nv - 5*nn;
214 writeline(
'-', 79,
false,
true);
216 for (
size_t n = 0; n < nrem; n++) {
219 writeline(
'-', 79,
false,
true);
220 for (
size_t j = 0; j < m_points; j++) {
222 for (
size_t n = 0; n < nrem; n++) {
223 double v = value(x, nn*5+n, j);
230 void Domain1D::setProfile(
const std::string& name,
double* values,
double* soln)
232 for (
size_t n = 0; n < m_nv; n++) {
234 for (
size_t j = 0; j < m_points; j++) {
235 soln[index(n, j) +
m_iloc] = values[j];
240 throw CanteraError(
"Domain1D::setProfile",
"unknown component: "+name);
245 for (
size_t j = 0; j < m_points; j++) {
246 for (
size_t n = 0; n < m_nv; n++) {
Base class for exceptions thrown by Cantera classes.
size_t lastPoint() const
The index of the last (i.e., right-most) grid point belonging to this domain.
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain.
size_t nComponents() const
Number of components at each grid point.
virtual doublereal initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
virtual void showSolution(const doublereal *x)
Print the solution.
doublereal atol(size_t n)
Absolute tolerance of the nth component.
size_t nPoints() const
Number of grid points in this domain.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void setSteadyTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for steady-state mode.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
virtual void resize(size_t nv, size_t np)
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void _getInitialSoln(doublereal *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
doublereal rtol(size_t n)
Relative tolerance of the nth component.
virtual size_t componentIndex(const std::string &name) const
index of component with name name.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
void locate()
Find the index of the first grid point in this domain, and the start of its variables in the global s...
void setTransientTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for time-stepping mode.
void setAge(int age)
Set the Jacobian age.
An error indicating that an unimplemented function has been called.
void saveStats()
Save statistics on function and Jacobian evaluation, and reset the counters.
MultiJac & jacobian()
Return a reference to the Jacobian evaluator.
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Class XML_Node is a tree-based representation of the contents of an XML file.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
const size_t npos
index returned by functions to indicate "no position"
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Namespace for the Cantera kernel.
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name,...
void addFloatArray(XML_Node &node, const std::string &title, const size_t n, const doublereal *const vals, const std::string &units, const std::string &type, const doublereal minval, const doublereal maxval)
This function adds a child node with the name, "floatArray", with a value consisting of a comma separ...