Cantera
2.3.0
|
Base class for one-dimensional domains. More...
#include <Domain1D.h>
Public Member Functions | |
Domain1D (size_t nv=1, size_t points=1, double time=0.0) | |
Constructor. More... | |
int | domainType () |
Domain type flag. More... | |
size_t | domainIndex () |
The left-to-right location of this domain. More... | |
bool | isConnector () |
True if the domain is a connector domain. More... | |
const OneDim & | container () const |
The container holding this domain. More... | |
void | setContainer (OneDim *c, size_t index) |
Specify the container object for this domain, and the position of this domain in the list. More... | |
void | setBandwidth (int bw=-1) |
Set the Jacobian bandwidth. See the discussion of method bandwidth(). More... | |
size_t | bandwidth () |
Set the Jacobian bandwidth for this domain. More... | |
virtual void | init () |
virtual void | setInitialState (doublereal *xlocal=0) |
virtual void | setState (size_t point, const doublereal *state, doublereal *x) |
virtual void | resetBadValues (double *xg) |
virtual void | resize (size_t nv, size_t np) |
Refiner & | refiner () |
Return a reference to the grid refiner. More... | |
size_t | nComponents () const |
Number of components at each grid point. More... | |
void | checkComponentIndex (size_t n) const |
Check that the specified component index is in range. More... | |
void | checkComponentArraySize (size_t nn) const |
Check that an array size is at least nComponents(). More... | |
size_t | nPoints () const |
Number of grid points in this domain. More... | |
void | checkPointIndex (size_t n) const |
Check that the specified point index is in range. More... | |
void | checkPointArraySize (size_t nn) const |
Check that an array size is at least nPoints(). More... | |
virtual std::string | componentName (size_t n) const |
Name of the nth component. May be overloaded. More... | |
void | setComponentName (size_t n, const std::string &name) |
void | setComponentType (size_t n, int ctype) |
size_t | componentIndex (const std::string &name) const |
index of component with name name. More... | |
void | setBounds (size_t n, doublereal lower, doublereal upper) |
void | setTransientTolerances (doublereal rtol, doublereal atol, size_t n=npos) |
Set tolerances for time-stepping mode. More... | |
void | setSteadyTolerances (doublereal rtol, doublereal atol, size_t n=npos) |
Set tolerances for steady-state mode. More... | |
doublereal | rtol (size_t n) |
Relative tolerance of the nth component. More... | |
doublereal | atol (size_t n) |
Absolute tolerance of the nth component. More... | |
double | steady_rtol (size_t n) |
Steady relative tolerance of the nth component. More... | |
double | steady_atol (size_t n) |
Steady absolute tolerance of the nth component. More... | |
double | transient_rtol (size_t n) |
Transient relative tolerance of the nth component. More... | |
double | transient_atol (size_t n) |
Transient absolute tolerance of the nth component. More... | |
doublereal | upperBound (size_t n) const |
Upper bound on the nth component. More... | |
doublereal | lowerBound (size_t n) const |
Lower bound on the nth component. More... | |
void | initTimeInteg (doublereal dt, const doublereal *x0) |
Prepare to do time stepping with time step dt. More... | |
void | setSteadyMode () |
Prepare to solve the steady-state problem. More... | |
bool | steady () |
True if in steady-state mode. More... | |
bool | transient () |
True if not in steady-state mode. More... | |
void | needJacUpdate () |
void | evalss (doublereal *x, doublereal *r, integer *mask) |
virtual void | eval (size_t j, doublereal *x, doublereal *r, integer *mask, doublereal rdt=0.0) |
Evaluate the residual function at point j. More... | |
virtual doublereal | residual (doublereal *x, size_t n, size_t j) |
int | timeDerivativeFlag (size_t n) |
void | setAlgebraic (size_t n) |
virtual void | update (doublereal *x) |
doublereal | time () const |
void | incrementTime (doublereal dt) |
size_t | index (size_t n, size_t j) const |
doublereal | value (const doublereal *x, size_t n, size_t j) const |
virtual void | setJac (MultiJac *jac) |
virtual XML_Node & | save (XML_Node &o, const doublereal *const sol) |
Save the current solution for this domain into an XML_Node. More... | |
virtual void | restore (const XML_Node &dom, doublereal *soln, int loglevel) |
Restore the solution for this domain from an XML_Node. More... | |
size_t | size () const |
void | locate () |
Find the index of the first grid point in this domain, and the start of its variables in the global solution vector. More... | |
virtual size_t | loc (size_t j=0) const |
Location of the start of the local solution vector in the global solution vector,. More... | |
size_t | firstPoint () const |
The index of the first (i.e., left-most) grid point belonging to this domain. More... | |
size_t | lastPoint () const |
The index of the last (i.e., right-most) grid point belonging to this domain. More... | |
void | linkLeft (Domain1D *left) |
Set the left neighbor to domain 'left. More... | |
void | linkRight (Domain1D *right) |
Set the right neighbor to domain 'right.'. More... | |
void | append (Domain1D *right) |
Append domain 'right' to this one, and update all links. More... | |
Domain1D * | left () const |
Return a pointer to the left neighbor. More... | |
Domain1D * | right () const |
Return a pointer to the right neighbor. More... | |
double | prevSoln (size_t n, size_t j) const |
Value of component n at point j in the previous solution. More... | |
void | setID (const std::string &s) |
Specify an identifying tag for this domain. More... | |
std::string | id () const |
void | setDesc (const std::string &s) |
Specify descriptive text for this domain. More... | |
const std::string & | desc () |
virtual void | getTransientMask (integer *mask) |
virtual void | showSolution_s (std::ostream &s, const doublereal *x) |
virtual void | showSolution (const doublereal *x) |
Print the solution. More... | |
doublereal | z (size_t jlocal) const |
doublereal | zmin () const |
doublereal | zmax () const |
void | setProfile (const std::string &name, double *values, double *soln) |
vector_fp & | grid () |
const vector_fp & | grid () const |
doublereal | grid (size_t point) const |
virtual void | setupGrid (size_t n, const doublereal *z) |
called to set up initial grid, and after grid refinement More... | |
virtual void | _getInitialSoln (doublereal *x) |
Writes some or all initial solution values into the global solution array, beginning at the location pointed to by x. More... | |
virtual doublereal | initialValue (size_t n, size_t j) |
Initial value of solution component n at grid point j. More... | |
virtual void | _finalize (const doublereal *x) |
In some cases, a domain may need to set parameters that depend on the initial solution estimate. More... | |
void | forceFullUpdate (bool update) |
In some cases, for computational efficiency some properties (e.g. More... | |
Protected Attributes | |
doublereal | m_rdt |
size_t | m_nv |
size_t | m_points |
vector_fp | m_slast |
doublereal | m_time |
vector_fp | m_max |
vector_fp | m_min |
vector_fp | m_rtol_ss |
vector_fp | m_rtol_ts |
vector_fp | m_atol_ss |
vector_fp | m_atol_ts |
vector_fp | m_z |
OneDim * | m_container |
size_t | m_index |
int | m_type |
size_t | m_iloc |
Starting location within the solution vector for unknowns that correspond to this domain. More... | |
size_t | m_jstart |
Domain1D * | m_left |
Domain1D * | m_right |
std::string | m_id |
Identity tag for the domain. More... | |
std::string | m_desc |
std::unique_ptr< Refiner > | m_refiner |
vector_int | m_td |
std::vector< std::string > | m_name |
int | m_bw |
bool | m_force_full_update |
Base class for one-dimensional domains.
Definition at line 36 of file Domain1D.h.
Domain1D | ( | size_t | nv = 1 , |
size_t | points = 1 , |
||
double | time = 0.0 |
||
) |
Constructor.
nv | Number of variables at each grid point. |
points | Number of grid points. |
time | (unused) |
Definition at line 17 of file Domain1D.cpp.
|
inline |
|
inline |
The left-to-right location of this domain.
Definition at line 55 of file Domain1D.h.
|
inline |
True if the domain is a connector domain.
Definition at line 60 of file Domain1D.h.
|
inline |
The container holding this domain.
Definition at line 65 of file Domain1D.h.
|
inline |
Specify the container object for this domain, and the position of this domain in the list.
Definition at line 71 of file Domain1D.h.
|
inline |
Set the Jacobian bandwidth. See the discussion of method bandwidth().
Definition at line 77 of file Domain1D.h.
|
inline |
Set the Jacobian bandwidth for this domain.
When class OneDim computes the bandwidth of the overall multi-domain problem (in OneDim::resize()), it calls this method for the bandwidth of each domain. If setBandwidth has not been called, then a negative bandwidth is returned, in which case OneDim assumes that this domain is dense – that is, at each point, all components depend on the value of all other components at that point. In this case, the bandwidth is bw = 2*nComponents() - 1. However, if this domain contains some components that are uncoupled from other components at the same point, then this default bandwidth may greatly overestimate the true bandwidth, with a substantial penalty in performance. For such domains, use method setBandwidth to specify the bandwidth before passing this domain to the Sim1D or OneDim constructor.
Definition at line 96 of file Domain1D.h.
|
inlinevirtual |
Initialize. This method is called by OneDim::init() for each domain once at the beginning of a simulation. Base class method does nothing, but may be overloaded.
Reimplemented in ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, Inlet1D, and Bdry1D.
Definition at line 105 of file Domain1D.h.
|
inlinevirtual |
When called, this function should reset "bad" values in the state vector such as negative species concentrations. This function may be called after a failed solution attempt.
Reimplemented in ReactingSurf1D, and StFlow.
Definition at line 115 of file Domain1D.h.
|
virtual |
Resize the domain to have nv components and np grid points. This method is virtual so that subclasses can perform other actions required to resize the domain.
Reimplemented in StFlow.
Definition at line 34 of file Domain1D.cpp.
References Domain1D::locate(), and Domain1D::m_td.
Referenced by StFlow::resize(), Sim1D::restore(), Outlet1D::restore(), OutletRes1D::restore(), Surf1D::restore(), ReactingSurf1D::restore(), and Domain1D::setupGrid().
|
inline |
Return a reference to the grid refiner.
Definition at line 125 of file Domain1D.h.
Referenced by Sim1D::maxGridPoints(), StFlow::save(), Sim1D::setGridMin(), Sim1D::setMaxGridPoints(), and Sim1D::setRefineCriteria().
|
inline |
Number of components at each grid point.
Definition at line 130 of file Domain1D.h.
Referenced by OneDim::component(), Domain1D::componentIndex(), Outlet1D::eval(), OutletRes1D::eval(), Surf1D::eval(), ReactingSurf1D::eval(), OutletRes1D::init(), Domain1D::restore(), and MultiNewton::step().
|
inline |
Check that the specified component index is in range.
Throws an exception if n is greater than nComponents()-1
Definition at line 136 of file Domain1D.h.
|
inline |
Check that an array size is at least nComponents().
Throws an exception if nn is less than nComponents(). Used before calls which take an array pointer.
Definition at line 145 of file Domain1D.h.
|
inline |
Number of grid points in this domain.
Definition at line 152 of file Domain1D.h.
Referenced by ReactingSurf1D::eval(), StFlow::save(), and Sim1D::setFlatProfile().
|
inline |
Check that the specified point index is in range.
Throws an exception if n is greater than nPoints()-1
Definition at line 158 of file Domain1D.h.
|
inline |
Check that an array size is at least nPoints().
Throws an exception if nn is less than nPoints(). Used before calls which take an array pointer.
Definition at line 167 of file Domain1D.h.
|
virtual |
Name of the nth component. May be overloaded.
Reimplemented in ReactingSurf1D, and StFlow.
Definition at line 58 of file Domain1D.cpp.
Referenced by OneDim::component(), Domain1D::componentIndex(), Domain1D::showSolution(), and MultiNewton::step().
|
inline |
Definition at line 181 of file Domain1D.h.
References Domain1D::setAlgebraic(), and Cantera::warn_deprecated().
size_t componentIndex | ( | const std::string & | name | ) | const |
index of component with name name.
Definition at line 67 of file Domain1D.cpp.
References Domain1D::componentName(), and Domain1D::nComponents().
void setTransientTolerances | ( | doublereal | rtol, |
doublereal | atol, | ||
size_t | n = npos |
||
) |
Set tolerances for time-stepping mode.
rtol | Relative tolerance |
atol | Absolute tolerance |
n | component index these tolerances apply to. If set to -1 (the default), these tolerances will be applied to all solution components. |
Definition at line 78 of file Domain1D.cpp.
References Domain1D::atol(), Cantera::npos, and Domain1D::rtol().
void setSteadyTolerances | ( | doublereal | rtol, |
doublereal | atol, | ||
size_t | n = npos |
||
) |
Set tolerances for steady-state mode.
rtol | Relative tolerance |
atol | Absolute tolerance |
n | component index these tolerances apply to. If set to -1 (the default), these tolerances will be applied to all solution components. |
Definition at line 91 of file Domain1D.cpp.
References Domain1D::atol(), Cantera::npos, and Domain1D::rtol().
|
inline |
Relative tolerance of the nth component.
Definition at line 218 of file Domain1D.h.
Referenced by Domain1D::setSteadyTolerances(), and Domain1D::setTransientTolerances().
|
inline |
Absolute tolerance of the nth component.
Definition at line 223 of file Domain1D.h.
Referenced by Domain1D::setSteadyTolerances(), and Domain1D::setTransientTolerances().
|
inline |
Steady relative tolerance of the nth component.
Definition at line 228 of file Domain1D.h.
|
inline |
Steady absolute tolerance of the nth component.
Definition at line 233 of file Domain1D.h.
|
inline |
Transient relative tolerance of the nth component.
Definition at line 238 of file Domain1D.h.
|
inline |
Transient absolute tolerance of the nth component.
Definition at line 243 of file Domain1D.h.
|
inline |
Upper bound on the nth component.
Definition at line 248 of file Domain1D.h.
|
inline |
Lower bound on the nth component.
Definition at line 253 of file Domain1D.h.
|
inline |
Prepare to do time stepping with time step dt.
Copy the internally-stored solution at the last time step to array x0.
Definition at line 261 of file Domain1D.h.
References Domain1D::loc().
|
inline |
Prepare to solve the steady-state problem.
Set the internally-stored reciprocal of the time step to 0.0
Definition at line 270 of file Domain1D.h.
|
inline |
True if in steady-state mode.
Definition at line 275 of file Domain1D.h.
|
inline |
True if not in steady-state mode.
Definition at line 280 of file Domain1D.h.
void needJacUpdate | ( | ) |
Set this if something has changed in the governing equations (e.g. the value of a constant has been changed, so that the last-computed Jacobian is no longer valid.
Definition at line 104 of file Domain1D.cpp.
References OneDim::jacobian(), OneDim::saveStats(), and MultiJac::setAge().
Referenced by OutletRes1D::setMoleFractions(), and Inlet1D::setSpreadRate().
|
inline |
Evaluate the steady-state residual at all points, even if in transient mode. Used only to print diagnostic output.
Definition at line 296 of file Domain1D.h.
References Domain1D::eval(), Cantera::npos, and Cantera::warn_deprecated().
|
virtual |
Evaluate the residual function at point j.
If j == npos, evaluate the residual function at all points.
This function must be implemented in classes derived from Domain1D.
j | Grid point at which to update the residual | |
[in] | x | State vector |
[out] | r | residual vector |
[out] | mask | Boolean mask indicating whether each solution component has a time derivative (1) or not (0). |
[in] | rdt | Reciprocal of the timestep (rdt=0 implies steady- state.) |
Reimplemented in ReactingSurf1D, Surf1D, OutletRes1D, StFlow, Outlet1D, Symm1D, Empty1D, and Inlet1D.
Definition at line 112 of file Domain1D.cpp.
References Domain1D::firstPoint(), Domain1D::lastPoint(), Domain1D::loc(), Cantera::npos, Domain1D::prevSoln(), Domain1D::residual(), Domain1D::timeDerivativeFlag(), and Cantera::warn_deprecated().
Referenced by Domain1D::evalss().
|
inlinevirtual |
Derived classes should implement eval() instead.
Definition at line 319 of file Domain1D.h.
References Cantera::warn_deprecated().
Referenced by Domain1D::eval().
|
inline |
Definition at line 325 of file Domain1D.h.
References Domain1D::m_td, and Cantera::warn_deprecated().
Referenced by Domain1D::eval().
|
inline |
Definition at line 332 of file Domain1D.h.
References Domain1D::m_td, and Cantera::warn_deprecated().
Referenced by Domain1D::setComponentType().
|
inlinevirtual |
Definition at line 339 of file Domain1D.h.
References Cantera::warn_deprecated().
Referenced by Domain1D::forceFullUpdate().
|
inline |
Definition at line 344 of file Domain1D.h.
References Domain1D::m_time, and Cantera::warn_deprecated().
|
inline |
Definition at line 349 of file Domain1D.h.
References Domain1D::m_time, and Cantera::warn_deprecated().
Save the current solution for this domain into an XML_Node.
Base class version of the general domain1D save function. Derived classes should call the base class method in addition to saving their own data.
o | XML_Node to save the solution to. |
sol | Current value of the solution vector. The object will pick out which part of the solution vector pertains to this object. |
Reimplemented in FreeFlame, ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, StFlow, and Inlet1D.
Definition at line 160 of file Domain1D.cpp.
Referenced by StFlow::save(), Outlet1D::save(), OutletRes1D::save(), Surf1D::save(), and ReactingSurf1D::save().
|
virtual |
Restore the solution for this domain from an XML_Node.
Base class version of the general Domain1D restore function. Derived classes should call the base class method in addition to restoring their own data.
dom | XML_Node for this domain |
soln | Current value of the solution vector, local to this object. |
loglevel | 0 to suppress all output; 1 to show warnings; 2 for verbose output |
Reimplemented in FreeFlame, ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, StFlow, and Inlet1D.
Definition at line 173 of file Domain1D.cpp.
References XML_Node::getChildren(), Cantera::getFloatArray(), Domain1D::nComponents(), and Cantera::writelog().
Referenced by StFlow::restore(), Sim1D::restore(), Outlet1D::restore(), OutletRes1D::restore(), Surf1D::restore(), and ReactingSurf1D::restore().
void locate | ( | ) |
Find the index of the first grid point in this domain, and the start of its variables in the global solution vector.
Definition at line 214 of file Domain1D.cpp.
References Domain1D::lastPoint(), Domain1D::loc(), Domain1D::locate(), and Domain1D::m_iloc.
Referenced by Domain1D::linkLeft(), Domain1D::locate(), and Domain1D::resize().
|
inlinevirtual |
Location of the start of the local solution vector in the global solution vector,.
Definition at line 403 of file Domain1D.h.
References Domain1D::m_iloc.
Referenced by Outlet1D::eval(), StFlow::eval(), OutletRes1D::eval(), Surf1D::eval(), ReactingSurf1D::eval(), Domain1D::eval(), Domain1D::initTimeInteg(), Domain1D::locate(), StFlow::resetBadValues(), ReactingSurf1D::resetBadValues(), StFlow::save(), ReactingSurf1D::save(), Sim1D::setValue(), and Sim1D::value().
|
inline |
The index of the first (i.e., left-most) grid point belonging to this domain.
Definition at line 411 of file Domain1D.h.
Referenced by Outlet1D::eval(), StFlow::eval(), OutletRes1D::eval(), Surf1D::eval(), ReactingSurf1D::eval(), and Domain1D::eval().
|
inline |
The index of the last (i.e., right-most) grid point belonging to this domain.
Definition at line 419 of file Domain1D.h.
Referenced by Outlet1D::eval(), StFlow::eval(), OutletRes1D::eval(), Surf1D::eval(), ReactingSurf1D::eval(), Domain1D::eval(), and Domain1D::locate().
|
inline |
Set the left neighbor to domain 'left.
' Method 'locate' is called to update the global positions of this domain and all those to its right.
Definition at line 427 of file Domain1D.h.
References Domain1D::left(), and Domain1D::locate().
Referenced by Domain1D::append().
|
inline |
Set the right neighbor to domain 'right.'.
Definition at line 433 of file Domain1D.h.
References Domain1D::right().
Referenced by Domain1D::append().
|
inline |
Append domain 'right' to this one, and update all links.
Definition at line 438 of file Domain1D.h.
References Domain1D::linkLeft(), Domain1D::linkRight(), and Domain1D::right().
|
inline |
Return a pointer to the left neighbor.
Definition at line 444 of file Domain1D.h.
Referenced by Domain1D::linkLeft().
|
inline |
Return a pointer to the right neighbor.
Definition at line 449 of file Domain1D.h.
Referenced by Domain1D::append(), and Domain1D::linkRight().
|
inline |
Value of component n at point j in the previous solution.
Definition at line 454 of file Domain1D.h.
Referenced by ReactingSurf1D::eval(), and Domain1D::eval().
|
inline |
Specify an identifying tag for this domain.
Definition at line 459 of file Domain1D.h.
References Domain1D::m_id.
|
inline |
Specify descriptive text for this domain.
Definition at line 473 of file Domain1D.h.
References Cantera::warn_deprecated().
|
inline |
Definition at line 479 of file Domain1D.h.
References Cantera::warn_deprecated().
|
inlinevirtual |
Definition at line 485 of file Domain1D.h.
References Cantera::warn_deprecated().
|
virtual |
Print the solution.
Reimplemented in ReactingSurf1D, Surf1D, OutletRes1D, Empty1D, StFlow, and Inlet1D.
Definition at line 244 of file Domain1D.cpp.
References Domain1D::componentName(), and Cantera::writelog().
Referenced by StFlow::showSolution().
|
virtual |
called to set up initial grid, and after grid refinement
Reimplemented in Bdry1D, and StFlow.
Definition at line 234 of file Domain1D.cpp.
References Domain1D::resize().
Referenced by Sim1D::restoreSteadySolution().
|
virtual |
Writes some or all initial solution values into the global solution array, beginning at the location pointed to by x.
This method is called by the Sim1D constructor, and allows default values or ones that have been set locally prior to installing this domain into the container to be written to the global solution vector.
Reimplemented in ReactingSurf1D, and StFlow.
Definition at line 293 of file Domain1D.cpp.
References Domain1D::initialValue().
Referenced by Sim1D::Sim1D().
|
virtual |
Initial value of solution component n at grid point j.
Definition at line 302 of file Domain1D.cpp.
Referenced by Domain1D::_getInitialSoln().
|
inlinevirtual |
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
In such cases, the parameters may be set in method _finalize. This method is called just before the Newton solver is called, and the x array is guaranteed to be the local solution vector for this domain that will be used as the initial guess. If no such parameters need to be set, then method _finalize does not need to be overloaded.
Reimplemented in FreeFlame, ReactingSurf1D, and StFlow.
Definition at line 540 of file Domain1D.h.
Referenced by Sim1D::finalize().
|
inline |
In some cases, for computational efficiency some properties (e.g.
transport coefficients) may not be updated during Jacobian evaluations. Set this to true
to force these properties to be udpated even while calculating Jacobian elements.
Definition at line 548 of file Domain1D.h.
References Domain1D::update().
|
protected |
Definition at line 557 of file Domain1D.h.
Referenced by Domain1D::incrementTime(), and Domain1D::time().
|
protected |
Starting location within the solution vector for unknowns that correspond to this domain.
Remember there may be multiple domains associated with this problem
Definition at line 572 of file Domain1D.h.
Referenced by Domain1D::loc(), and Domain1D::locate().
|
protected |
Identity tag for the domain.
Definition at line 579 of file Domain1D.h.
Referenced by Domain1D::setID().
|
protected |
Definition at line 582 of file Domain1D.h.
Referenced by Domain1D::resize(), Domain1D::setAlgebraic(), and Domain1D::timeDerivativeFlag().