38 explicit Domain1D(
size_t nv=1,
size_t points=1,
double time=0.0);
135 virtual void resize(
size_t nv,
size_t np);
165 virtual size_t componentIndex(
const string& name,
bool checkAlias=
true)
const;
174 virtual bool hasComponent(
const string& name,
bool checkAlias=
true)
const;
188 "Not implemented for domain type '{}'.",
domainType());
274 if (mode !=
"finite-difference" && mode !=
"analytic" && mode !=
"auto") {
276 "Unknown Jacobian mode '{}'", mode);
318 double slope = 0.8,
double curve = 0.8,
319 double prune = -0.1);
336 auto local = x0.subspan(
loc(),
size());
337 std::copy(local.begin(), local.end(),
m_slast.begin());
351 return (
m_rdt == 0.0);
356 return (
m_rdt != 0.0);
378 virtual void eval(
size_t j, span<const double> x, span<double> r, span<int> mask,
390 size_t index(
size_t n,
size_t j)
const {
400 virtual double value(
const string& component)
const {
402 "Not implemented for domain type '{}'.",
domainType());
414 "Not implemented for domain type '{}'.",
domainType());
424 vector<double>
values(
const string& component)
const {
425 vector<double> data(
nPoints());
439 "Not implemented for domain type '{}'.",
domainType());
451 "Not implemented for domain type '{}'.",
domainType());
463 vector<double>
residuals(
const string& component)
const {
464 vector<double> data(
nPoints());
481 "Not applicable or not implemented for domain type '{}'.",
domainType());
500 span<const double> pos, span<const double>
values) {
502 "Not implemented for domain type '{}'.",
domainType());
514 "Not implemented for domain type '{}'.",
domainType());
525 virtual shared_ptr<SolutionArray>
toArray(
bool normalize=
false) {
535 virtual void fromArray(
const shared_ptr<SolutionArray>& arr) {
548 string info(
const vector<string>& keys,
int rows=10,
int width=80);
558 string _info(
int rows=10,
int width=80) {
559 return info({}, rows, width);
564 shared_ptr<Solution>
phase()
const {
580 virtual size_t loc(
size_t j = 0)
const {
639 return fmt::format(
"domain {}",
m_index);
645 virtual void show(span<const double> x);
648 double z(
size_t jlocal)
const {
668 span<const double>
grid()
const {
717 void setData(shared_ptr<vector<double>>& data) {
A map of string keys to values whose type can vary at runtime.
Base class for exceptions thrown by Cantera classes.
Base class for one-dimensional domains.
virtual void setValues(const string &component, span< const double > values)
Specify component values.
void setTransientTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for time-stepping mode.
size_t lastPoint() const
The index of the last (that is, 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 domainIndex()
The left-to-right location of this domain.
virtual void _getInitialSoln(span< double > x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
Domain1D * m_left
Pointer to the domain to the left.
OneDim * m_container
Parent OneDim simulation containing this and adjacent domains.
void initTimeInteg(double dt, span< const double > x0)
Performs the setup required before starting a time-stepping solution.
bool transient()
True if not in steady-state mode.
void setComponentName(size_t n, const string &name)
Set the name of the component n to name.
virtual void setupGrid(span< const double > z)
Set up initial grid.
virtual void resetBadValues(span< double > x)
When called, this function should reset "bad" values in the state vector such as negative species con...
size_t nComponents() const
Number of components at each grid point.
size_t bandwidth()
Set the Jacobian bandwidth for this domain.
double rtol(size_t n)
Relative tolerance of the nth component.
void setJacobianMode(const string &mode)
Set the method used to evaluate this domain's Jacobian columns.
vector< double > m_atol_ss
Absolute tolerances for steady mode.
void setupUniformGrid(size_t points, double length, double start=0.)
Set up uniform grid.
vector< double > m_rtol_ts
Relative tolerances for transient mode.
size_t size() const
Return the size of the solution vector (the product of m_nv and m_points).
vector< double > m_atol_ts
Absolute tolerances for transient mode.
virtual void updateState(size_t loc)
Update state at given location to state of associated Solution object.
virtual bool isConnector()
True if the domain is a connector domain.
string _info(int rows=10, int width=80)
Return a concise summary of a Domain.
virtual void evalJacobianAnalytic(span< const double > x, SystemJacobian &jac)
Add this domain's analytic Jacobian entries (for columns claimed by hasAnalyticJacobian()) to jac via...
virtual void _setKinetics(shared_ptr< Kinetics > kin)
Update transport model to existing instance.
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
size_t globalComponentIndex(const string &name, size_t j) const
Index of component name at grid point j within the global solution vector of the containing OneDim/Si...
size_t m_index
Left-to-right location of this domain.
Domain1D * left() const
Return a pointer to the left neighbor.
vector< double > residuals(const string &component) const
Retrieve internal work array values for a component.
string id() const
Returns the identifying tag for this domain.
double zmin() const
Get the coordinate [m] of the first (leftmost) grid point in this domain.
span< double > grid()
Access the array of grid coordinates [m].
size_t m_jstart
Index of the first point in this domain in the global point list.
shared_ptr< Solution > phase() const
Return thermo/kinetics/transport manager used in the domain.
size_t m_nv
Number of solution components.
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.
virtual bool hasAnalyticJacobian(size_t j, size_t n) const
Returns true if this domain computes the Jacobian column for component n at (domain-local) grid point...
void setContainer(OneDim *c, size_t index)
Specify the container object for this domain, and the position of this domain in the list.
size_t nPoints() const
Number of grid points in this domain.
vector< string > m_name
Names of solution components.
double m_rdt
Reciprocal of the time step.
virtual string domainType() const
Domain type flag.
bool m_force_full_update
see forceFullUpdate()
string info(const vector< string > &keys, int rows=10, int width=80)
Return a concise summary of a Domain.
double lowerBound(size_t n) const
Lower bound on the nth component.
virtual void setTransportModel(const string &model)
Set transport model by name.
virtual size_t componentIndex(const string &name, bool checkAlias=true) const
Index of component with name name.
shared_ptr< vector< double > > m_state
data pointer shared from OneDim
void linkLeft(Domain1D *left)
Set the left neighbor to domain 'left.
span< const double > grid() const
Access the array of grid coordinates [m].
string m_jacobianMode
see setJacobianMode()
const string & jacobianMode() const
Get the method used to evaluate this domain's Jacobian columns.
vector< double > values(const string &component) const
Retrieve component values.
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
virtual void setValue(const string &component, double value)
Set a single component value in a flow domain or at a boundary.
double upperBound(size_t n) const
Upper bound on the nth component.
Refiner & refiner()
Return a reference to the grid refiner.
Domain1D * right() const
Return a pointer to the right neighbor.
vector< double > m_rtol_ss
Relative tolerances for steady mode.
double m_press
pressure [Pa]
vector< double > m_slast
Solution vector at the last time step.
virtual double value(const string &component) const
Set a single component value at a boundary.
virtual void fromArray(const shared_ptr< SolutionArray > &arr)
Restore the solution for this domain from a SolutionArray.
Domain1D * m_right
Pointer to the domain to the right.
double steady_atol(size_t n)
Steady absolute tolerance of the nth component.
void setSteadyTolerances(double rtol, double atol, size_t n=npos)
Set tolerances for steady-state mode.
virtual string componentName(size_t n) const
Name of component n. May be overloaded.
virtual void getResiduals(const string &component, span< double > values) const
Retrieve internal work array values for a component.
double transient_atol(size_t n)
Transient absolute tolerance of the nth component.
virtual void _setTransport(shared_ptr< Transport > trans)
Update transport model to existing instance.
virtual void init()
Initialize.
double atol(size_t n)
Absolute tolerance of the nth component.
void setID(const string &s)
Specify an identifying tag for this domain.
vector< double > m_z
1D spatial grid coordinates
void forceFullUpdate(bool update)
In some cases, for computational efficiency some properties (such as transport coefficients) may not ...
const OneDim & container() const
The container holding this domain.
size_t m_points
Number of grid points.
virtual void checkAnalyticJacobian() const
Validate that an explicitly requested analytic Jacobian (jacobian_mode == "analytic") can be used for...
bool steady()
True if in steady-state mode.
virtual void show(span< const double > x)
Print the solution.
void setBandwidth(int bw=-1)
Set the Jacobian bandwidth. See the discussion of method bandwidth().
double steady_rtol(size_t n)
Steady relative tolerance of the nth component.
string m_id
Identity tag for the domain.
vector< double > m_max
Upper bounds on solution components.
unique_ptr< Refiner > m_refiner
Refiner object used for placing grid points.
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
vector< double > m_min
Lower bounds on solution components.
void setData(shared_ptr< vector< double > > &data)
Set shared data pointer.
virtual void setProfile(const string &component, span< const double > pos, span< const double > values)
Specify a profile for a component.
void append(Domain1D *right)
Append domain 'right' to this one, and update all links.
void setSteadyMode()
Set the internally-stored reciprocal of the time step to 0.0, which is used to indicate that the prob...
virtual double initialValue(size_t n, size_t j)
Initial value of solution component n at grid point j.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
double zmax() const
Get the coordinate [m] of the last (rightmost) grid point in this domain.
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
virtual shared_ptr< SolutionArray > toArray(bool normalize=false)
Save the state of this domain to a SolutionArray.
void needJacUpdate()
Set this if something has changed in the governing equations (for example, the value of a constant ha...
void linkRight(Domain1D *right)
Set the right neighbor to domain 'right.'.
virtual void getValues(const string &component, span< double > values) const
Retrieve component values.
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.
vector< double > getRefineCriteria()
Get the grid refinement criteria.
double transient_rtol(size_t n)
Transient relative tolerance of the nth component.
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...
virtual void _finalize(span< const double > x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
virtual AnyMap getMeta() const
Retrieve meta data.
virtual bool hasComponent(const string &name, bool checkAlias=true) const
Check whether the Domain contains a component.
void setRefineCriteria(double ratio=10.0, double slope=0.8, double curve=0.8, double prune=-0.1)
Set grid refinement criteria.
virtual void setFlatProfile(const string &component, double value)
Specify a flat profile for a component.
An error indicating that an unimplemented function has been called.
Container class for multiple-domain 1D problems.
Refine Domain1D grids so that profiles satisfy adaptation tolerances.
Abstract base class representing Jacobian matrices and preconditioners used in nonlinear solvers.
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.
const size_t npos
index returned by functions to indicate "no position"