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 writelog(
"Warning: Domain1D::restore: Got an array of length {}" 133 " when one of length {} was expected. " 134 "Tolerances for individual species may not be preserved.\n",
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++) {
255 "base class method called!");
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...
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...
virtual void _getInitialSoln(doublereal *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
void locate()
Find the index of the first grid point in this domain, and the start of its variables in the global s...
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...
MultiJac & jacobian()
Return a reference to the Jacobian evaluator.
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain...
const size_t npos
index returned by functions to indicate "no position"
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual XML_Node & save(XML_Node &o, const doublereal *const sol)
Save the current solution for this domain into an XML_Node.
void setAge(int age)
Set the Jacobian age.
size_t lastPoint() const
The index of the last (i.e., right-most) grid point belonging to this domain.
virtual void resize(size_t nv, size_t np)
virtual void showSolution(const doublereal *x)
Print the solution.
Base class for exceptions thrown by Cantera classes.
void saveStats()
Save statistics on function and Jacobian evaluation, and reset the counters.
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
size_t componentIndex(const std::string &name) const
index of component with name name.
size_t nComponents() const
Number of components at each grid point.
void setSteadyTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for steady-state mode.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
doublereal atol(size_t n)
Absolute tolerance of the nth component.
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
doublereal rtol(size_t n)
Relative tolerance of the nth component.
size_t nPoints() const
Number of grid points in this domain.
Namespace for the Cantera kernel.
void setTransientTolerances(doublereal rtol, doublereal atol, size_t n=npos)
Set tolerances for time-stepping mode.
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector,.
virtual doublereal initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.