Base class for one-dimensional domains. More...
#include <Domain1D.h>
Base class for one-dimensional domains.
Definition at line 27 of file Domain1D.h.
Public Member Functions | |
Domain1D (size_t nv=1, size_t points=1, double time=0.0) | |
Constructor. | |
Domain1D (const Domain1D &)=delete | |
Domain1D & | operator= (const Domain1D &)=delete |
virtual string | domainType () const |
Domain type flag. | |
string | type () const |
String indicating the domain implemented. | |
size_t | domainIndex () |
The left-to-right location of this domain. | |
virtual bool | isConnector () |
True if the domain is a connector domain. | |
void | setSolution (shared_ptr< Solution > sol) |
Set the solution manager. | |
virtual void | setKinetics (shared_ptr< Kinetics > kin) |
Set the kinetics manager. | |
virtual void | setTransport (shared_ptr< Transport > trans) |
Set transport model to existing instance. | |
const OneDim & | container () const |
The container holding this domain. | |
void | setContainer (OneDim *c, size_t index) |
Specify the container object for this domain, and the position of this domain in the list. | |
void | setBandwidth (int bw=-1) |
Set the Jacobian bandwidth. See the discussion of method bandwidth(). | |
size_t | bandwidth () |
Set the Jacobian bandwidth for this domain. | |
virtual void | init () |
Initialize. | |
virtual void | setInitialState (double *xlocal=0) |
virtual void | setState (size_t point, const double *state, double *x) |
virtual void | resetBadValues (double *xg) |
When called, this function should reset "bad" values in the state vector such as negative species concentrations. | |
virtual void | resize (size_t nv, size_t np) |
Resize the domain to have nv components and np grid points. | |
Refiner & | refiner () |
Return a reference to the grid refiner. | |
size_t | nComponents () const |
Number of components at each grid point. | |
void | checkComponentIndex (size_t n) const |
Check that the specified component index is in range. | |
void | checkComponentArraySize (size_t nn) const |
Check that an array size is at least nComponents(). | |
size_t | nPoints () const |
Number of grid points in this domain. | |
void | checkPointIndex (size_t n) const |
Check that the specified point index is in range. | |
void | checkPointArraySize (size_t nn) const |
Check that an array size is at least nPoints(). | |
virtual string | componentName (size_t n) const |
Name of the nth component. May be overloaded. | |
void | setComponentName (size_t n, const string &name) |
virtual size_t | componentIndex (const string &name) const |
index of component with name name. | |
void | setBounds (size_t n, double lower, double upper) |
void | setTransientTolerances (double rtol, double atol, size_t n=npos) |
Set tolerances for time-stepping mode. | |
void | setSteadyTolerances (double rtol, double atol, size_t n=npos) |
Set tolerances for steady-state mode. | |
double | rtol (size_t n) |
Relative tolerance of the nth component. | |
double | atol (size_t n) |
Absolute tolerance of the nth component. | |
double | steady_rtol (size_t n) |
Steady relative tolerance of the nth component. | |
double | steady_atol (size_t n) |
Steady absolute tolerance of the nth component. | |
double | transient_rtol (size_t n) |
Transient relative tolerance of the nth component. | |
double | transient_atol (size_t n) |
Transient absolute tolerance of the nth component. | |
double | upperBound (size_t n) const |
Upper bound on the nth component. | |
double | lowerBound (size_t n) const |
Lower bound on the nth component. | |
void | initTimeInteg (double dt, const double *x0) |
Prepare to do time stepping with time step dt. | |
void | setSteadyMode () |
Prepare to solve the steady-state problem. | |
bool | steady () |
True if in steady-state mode. | |
bool | transient () |
True if not in steady-state mode. | |
void | needJacUpdate () |
Set this if something has changed in the governing equations (for example, the value of a constant has been changed, so that the last-computed Jacobian is no longer valid. | |
virtual void | eval (size_t j, double *x, double *r, integer *mask, double rdt=0.0) |
Evaluate the residual function at point j. | |
size_t | index (size_t n, size_t j) const |
double | value (const double *x, size_t n, size_t j) const |
virtual void | setJac (MultiJac *jac) |
virtual shared_ptr< SolutionArray > | asArray (const double *soln) const |
Save the state of this domain as a SolutionArray. | |
shared_ptr< SolutionArray > | toArray (bool normalize=false) const |
Save the state of this domain to a SolutionArray. | |
virtual void | fromArray (SolutionArray &arr, double *soln) |
Restore the solution for this domain from a SolutionArray. | |
void | fromArray (const shared_ptr< SolutionArray > &arr) |
Restore the solution for this domain from a SolutionArray. | |
shared_ptr< Solution > | solution () const |
Return thermo/kinetics/transport manager used in the domain. | |
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. | |
virtual size_t | loc (size_t j=0) const |
Location of the start of the local solution vector in the global solution vector,. | |
size_t | firstPoint () const |
The index of the first (that is, left-most) grid point belonging to this domain. | |
size_t | lastPoint () const |
The index of the last (that is, right-most) grid point belonging to this domain. | |
void | linkLeft (Domain1D *left) |
Set the left neighbor to domain 'left. | |
void | linkRight (Domain1D *right) |
Set the right neighbor to domain 'right.'. | |
void | append (Domain1D *right) |
Append domain 'right' to this one, and update all links. | |
Domain1D * | left () const |
Return a pointer to the left neighbor. | |
Domain1D * | right () const |
Return a pointer to the right neighbor. | |
double | prevSoln (size_t n, size_t j) const |
Value of component n at point j in the previous solution. | |
void | setID (const string &s) |
Specify an identifying tag for this domain. | |
string | id () const |
virtual void | show (std::ostream &s, const double *x) |
Print the solution. | |
virtual void | show (const double *x) |
Print the solution. | |
double | z (size_t jlocal) const |
double | zmin () const |
double | zmax () const |
void | setProfile (const string &name, double *values, double *soln) |
vector< double > & | grid () |
const vector< double > & | grid () const |
double | grid (size_t point) const |
virtual void | setupGrid (size_t n, const double *z) |
called to set up initial grid, and after grid refinement | |
virtual void | _getInitialSoln (double *x) |
Writes some or all initial solution values into the global solution array, beginning at the location pointed to by x. | |
virtual double | initialValue (size_t n, size_t j) |
Initial value of solution component n at grid point j. | |
virtual void | _finalize (const double *x) |
In some cases, a domain may need to set parameters that depend on the initial solution estimate. | |
void | forceFullUpdate (bool update) |
In some cases, for computational efficiency some properties (such as transport coefficients) may not be updated during Jacobian evaluations. | |
void | setData (shared_ptr< vector< double > > &data) |
Set shared data pointer. | |
Protected Member Functions | |
virtual AnyMap | getMeta () const |
Retrieve meta data. | |
virtual void | setMeta (const AnyMap &meta) |
Retrieve meta data. | |
Protected Attributes | |
shared_ptr< vector< double > > | m_state |
data pointer shared from OneDim | |
double | m_rdt = 0.0 |
size_t | m_nv = 0 |
size_t | m_points |
Number of grid points. | |
vector< double > | m_slast |
vector< double > | m_max |
vector< double > | m_min |
vector< double > | m_rtol_ss |
vector< double > | m_rtol_ts |
vector< double > | m_atol_ss |
vector< double > | m_atol_ts |
vector< double > | m_z |
OneDim * | m_container = nullptr |
size_t | m_index |
size_t | m_iloc = 0 |
Starting location within the solution vector for unknowns that correspond to this domain. | |
size_t | m_jstart = 0 |
Domain1D * | m_left = nullptr |
Domain1D * | m_right = nullptr |
string | m_id |
Identity tag for the domain. | |
unique_ptr< Refiner > | m_refiner |
vector< string > | m_name |
int | m_bw = -1 |
bool | m_force_full_update = false |
shared_ptr< Solution > | m_solution |
Composite thermo/kinetics/transport handler. | |
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 19 of file Domain1D.cpp.
|
virtual |
Definition at line 24 of file Domain1D.cpp.
|
inlinevirtual |
Domain type flag.
string
. Reimplemented in Boundary1D, Inlet1D, Empty1D, Symm1D, Outlet1D, OutletRes1D, Surf1D, ReactingSurf1D, IonFlow, and StFlow.
Definition at line 44 of file Domain1D.h.
|
inline |
String indicating the domain implemented.
Definition at line 49 of file Domain1D.h.
|
inline |
The left-to-right location of this domain.
Definition at line 52 of file Domain1D.h.
|
inlinevirtual |
True if the domain is a connector domain.
Reimplemented in Boundary1D.
Definition at line 57 of file Domain1D.h.
void setSolution | ( | shared_ptr< Solution > | sol | ) |
|
inlinevirtual |
Set the kinetics manager.
Reimplemented in ReactingSurf1D, and StFlow.
Definition at line 67 of file Domain1D.h.
|
inlinevirtual |
Set transport model to existing instance.
Reimplemented in StFlow.
Definition at line 73 of file Domain1D.h.
|
inline |
The container holding this domain.
Definition at line 78 of file Domain1D.h.
|
inline |
Specify the container object for this domain, and the position of this domain in the list.
Definition at line 84 of file Domain1D.h.
|
inline |
Set the Jacobian bandwidth. See the discussion of method bandwidth().
Definition at line 90 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 109 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 Boundary1D, Inlet1D, Empty1D, Symm1D, Outlet1D, OutletRes1D, Surf1D, and ReactingSurf1D.
Definition at line 118 of file Domain1D.h.
|
inlinevirtual |
Definition at line 120 of file Domain1D.h.
|
inlinevirtual |
Definition at line 121 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 128 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 IonFlow, and StFlow.
Definition at line 44 of file Domain1D.cpp.
|
inline |
Return a reference to the grid refiner.
Definition at line 138 of file Domain1D.h.
|
inline |
Number of components at each grid point.
Definition at line 143 of file Domain1D.h.
|
inline |
Check that the specified component index is in range.
Throws an exception if n is greater than nComponents()-1
Definition at line 149 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 158 of file Domain1D.h.
|
inline |
Number of grid points in this domain.
Definition at line 165 of file Domain1D.h.
|
inline |
Check that the specified point index is in range.
Throws an exception if n is greater than nPoints()-1
Definition at line 171 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 180 of file Domain1D.h.
|
virtual |
Name of the nth component. May be overloaded.
Reimplemented in ReactingSurf1D, and StFlow.
Definition at line 67 of file Domain1D.cpp.
|
inline |
Definition at line 189 of file Domain1D.h.
|
virtual |
index of component with name name.
Reimplemented in StFlow.
Definition at line 76 of file Domain1D.cpp.
|
inline |
Definition at line 196 of file Domain1D.h.
void setTransientTolerances | ( | double | rtol, |
double | 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 87 of file Domain1D.cpp.
void setSteadyTolerances | ( | double | rtol, |
double | 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 100 of file Domain1D.cpp.
|
inline |
Relative tolerance of the nth component.
Definition at line 222 of file Domain1D.h.
|
inline |
Absolute tolerance of the nth component.
Definition at line 227 of file Domain1D.h.
|
inline |
Steady relative tolerance of the nth component.
Definition at line 232 of file Domain1D.h.
|
inline |
Steady absolute tolerance of the nth component.
Definition at line 237 of file Domain1D.h.
|
inline |
Transient relative tolerance of the nth component.
Definition at line 242 of file Domain1D.h.
|
inline |
Transient absolute tolerance of the nth component.
Definition at line 247 of file Domain1D.h.
|
inline |
Upper bound on the nth component.
Definition at line 252 of file Domain1D.h.
|
inline |
Lower bound on the nth component.
Definition at line 257 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 265 of file Domain1D.h.
|
inline |
Prepare to solve the steady-state problem.
Set the internally-stored reciprocal of the time step to 0.0
Definition at line 274 of file Domain1D.h.
|
inline |
True if in steady-state mode.
Definition at line 279 of file Domain1D.h.
|
inline |
True if not in steady-state mode.
Definition at line 284 of file Domain1D.h.
void needJacUpdate | ( | ) |
Set this if something has changed in the governing equations (for example, the value of a constant has been changed, so that the last-computed Jacobian is no longer valid.
Definition at line 113 of file Domain1D.cpp.
|
inlinevirtual |
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 Inlet1D, Empty1D, Symm1D, Outlet1D, OutletRes1D, Surf1D, ReactingSurf1D, and StFlow.
Definition at line 308 of file Domain1D.h.
|
inline |
Definition at line 312 of file Domain1D.h.
|
inline |
Definition at line 315 of file Domain1D.h.
|
inlinevirtual |
Definition at line 319 of file Domain1D.h.
|
inlinevirtual |
Save the state of this domain as a SolutionArray.
soln | local solution vector for this domain |
Reimplemented in Inlet1D, Empty1D, Symm1D, Outlet1D, OutletRes1D, Surf1D, ReactingSurf1D, and StFlow.
Definition at line 329 of file Domain1D.h.
shared_ptr< SolutionArray > toArray | ( | bool | normalize = false | ) | const |
Save the state of this domain to a SolutionArray.
This method serves as an external interface for high-level API's; it does not provide direct access to memory.
normalize | If true, normalize concentrations (default=false) |
Definition at line 149 of file Domain1D.cpp.
|
inlinevirtual |
Restore the solution for this domain from a SolutionArray.
[in] | arr | SolutionArray defining the state of this domain |
[out] | soln | Value of the solution vector, local to this domain |
Reimplemented in Boundary1D, Inlet1D, OutletRes1D, Surf1D, ReactingSurf1D, and StFlow.
Definition at line 350 of file Domain1D.h.
void fromArray | ( | const shared_ptr< SolutionArray > & | arr | ) |
Restore the solution for this domain from a SolutionArray.
This method serves as an external interface for high-level API's.
arr | SolutionArray defining the state of this domain |
Definition at line 161 of file Domain1D.cpp.
|
inline |
Return thermo/kinetics/transport manager used in the domain.
Definition at line 364 of file Domain1D.h.
|
inline |
Definition at line 368 of file Domain1D.h.
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 205 of file Domain1D.cpp.
|
inlinevirtual |
Location of the start of the local solution vector in the global solution vector,.
Definition at line 382 of file Domain1D.h.
|
inline |
The index of the first (that is, left-most) grid point belonging to this domain.
Definition at line 390 of file Domain1D.h.
|
inline |
The index of the last (that is, right-most) grid point belonging to this domain.
Definition at line 398 of file Domain1D.h.
|
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 406 of file Domain1D.h.
|
inline |
Set the right neighbor to domain 'right.'.
Definition at line 415 of file Domain1D.h.
|
inline |
Append domain 'right' to this one, and update all links.
Definition at line 423 of file Domain1D.h.
|
inline |
Return a pointer to the left neighbor.
Definition at line 429 of file Domain1D.h.
|
inline |
Return a pointer to the right neighbor.
Definition at line 434 of file Domain1D.h.
|
inline |
Value of component n at point j in the previous solution.
Definition at line 439 of file Domain1D.h.
|
inline |
Specify an identifying tag for this domain.
Definition at line 444 of file Domain1D.h.
|
inline |
Definition at line 448 of file Domain1D.h.
|
inlinevirtual |
|
virtual |
Print the solution.
Reimplemented in Inlet1D, Empty1D, OutletRes1D, Surf1D, ReactingSurf1D, and StFlow.
Definition at line 235 of file Domain1D.cpp.
|
inline |
Definition at line 462 of file Domain1D.h.
|
inline |
Definition at line 465 of file Domain1D.h.
|
inline |
Definition at line 468 of file Domain1D.h.
void setProfile | ( | const string & | name, |
double * | values, | ||
double * | soln | ||
) |
Definition at line 271 of file Domain1D.cpp.
|
inline |
Definition at line 474 of file Domain1D.h.
|
inline |
Definition at line 477 of file Domain1D.h.
|
inline |
Definition at line 480 of file Domain1D.h.
|
virtual |
called to set up initial grid, and after grid refinement
Reimplemented in Boundary1D, and StFlow.
Definition at line 225 of file Domain1D.cpp.
|
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 284 of file Domain1D.cpp.
|
virtual |
Initial value of solution component n at grid point j.
Definition at line 293 of file Domain1D.cpp.
|
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 ReactingSurf1D, IonFlow, and StFlow.
Definition at line 507 of file Domain1D.h.
|
inline |
In some cases, for computational efficiency some properties (such as transport coefficients) may not be updated during Jacobian evaluations.
Set this to true
to force these properties to be updated even while calculating Jacobian elements.
Definition at line 515 of file Domain1D.h.
|
inline |
Set shared data pointer.
Definition at line 520 of file Domain1D.h.
|
protectedvirtual |
|
protectedvirtual |
|
protected |
data pointer shared from OneDim
Definition at line 531 of file Domain1D.h.
|
protected |
Definition at line 533 of file Domain1D.h.
|
protected |
Definition at line 534 of file Domain1D.h.
|
protected |
Number of grid points.
Definition at line 535 of file Domain1D.h.
|
protected |
Definition at line 536 of file Domain1D.h.
|
protected |
Definition at line 537 of file Domain1D.h.
|
protected |
Definition at line 538 of file Domain1D.h.
|
protected |
Definition at line 539 of file Domain1D.h.
|
protected |
Definition at line 539 of file Domain1D.h.
|
protected |
Definition at line 540 of file Domain1D.h.
|
protected |
Definition at line 540 of file Domain1D.h.
|
protected |
Definition at line 541 of file Domain1D.h.
|
protected |
Definition at line 542 of file Domain1D.h.
|
protected |
Definition at line 543 of file Domain1D.h.
|
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 550 of file Domain1D.h.
|
protected |
Definition at line 552 of file Domain1D.h.
|
protected |
Definition at line 554 of file Domain1D.h.
|
protected |
Definition at line 555 of file Domain1D.h.
|
protected |
Identity tag for the domain.
Definition at line 558 of file Domain1D.h.
|
protected |
Definition at line 559 of file Domain1D.h.
|
protected |
Definition at line 560 of file Domain1D.h.
|
protected |
Definition at line 561 of file Domain1D.h.
|
protected |
Definition at line 562 of file Domain1D.h.
|
protected |
Composite thermo/kinetics/transport handler.
Definition at line 565 of file Domain1D.h.