Cantera  3.1.0a1
Domain1D Class Reference

Base class for one-dimensional domains. More...

#include <Domain1D.h>

Inheritance diagram for Domain1D:
[legend]

Detailed Description

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. More...
 
 Domain1D (const Domain1D &)=delete
 
Domain1Doperator= (const Domain1D &)=delete
 
virtual string domainType () const
 Domain type flag. More...
 
string type () const
 String indicating the domain implemented. More...
 
size_t domainIndex ()
 The left-to-right location of this domain. More...
 
virtual bool isConnector ()
 True if the domain is a connector domain. More...
 
void setSolution (shared_ptr< Solution > sol)
 Set the solution manager. More...
 
virtual void setKinetics (shared_ptr< Kinetics > kin)
 Set the kinetics manager. More...
 
virtual void setTransport (shared_ptr< Transport > trans)
 Set transport model to existing instance. More...
 
const OneDimcontainer () 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 ()
 Initialize. More...
 
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. More...
 
virtual void resize (size_t nv, size_t np)
 Resize the domain to have nv components and np grid points. More...
 
Refinerrefiner ()
 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 string componentName (size_t n) const
 Name of the nth component. May be overloaded. More...
 
void setComponentName (size_t n, const string &name)
 
virtual size_t componentIndex (const string &name) const
 index of component with name name. More...
 
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. More...
 
void setSteadyTolerances (double rtol, double atol, size_t n=npos)
 Set tolerances for steady-state mode. More...
 
double rtol (size_t n)
 Relative tolerance of the nth component. More...
 
double 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...
 
double upperBound (size_t n) const
 Upper bound on the nth component. More...
 
double lowerBound (size_t n) const
 Lower bound on the nth component. More...
 
void initTimeInteg (double dt, const double *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 ()
 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. More...
 
virtual void eval (size_t j, double *x, double *r, integer *mask, double rdt=0.0)
 Evaluate the residual function at point j. More...
 
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< SolutionArrayasArray (const double *soln) const
 Save the state of this domain as a SolutionArray. More...
 
shared_ptr< SolutionArraytoArray (bool normalize=false) const
 Save the state of this domain to a SolutionArray. More...
 
virtual void fromArray (SolutionArray &arr, double *soln)
 Restore the solution for this domain from a SolutionArray. More...
 
void fromArray (const shared_ptr< SolutionArray > &arr)
 Restore the solution for this domain from a SolutionArray. More...
 
shared_ptr< Solutionsolution () const
 Return thermo/kinetics/transport manager used in the domain. 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 (that is, left-most) grid point belonging to this domain. More...
 
size_t lastPoint () const
 The index of the last (that is, 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...
 
Domain1Dleft () const
 Return a pointer to the left neighbor. More...
 
Domain1Dright () 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 string &s)
 Specify an identifying tag for this domain. More...
 
string id () const
 
virtual void show (std::ostream &s, const double *x)
 Print the solution. More...
 
virtual void show (const double *x)
 Print the solution. More...
 
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 More...
 
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. More...
 
virtual double initialValue (size_t n, size_t j)
 Initial value of solution component n at grid point j. More...
 
virtual void _finalize (const double *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 (such as transport coefficients) may not be updated during Jacobian evaluations. More...
 
void setData (shared_ptr< vector< double >> &data)
 Set shared data pointer. More...
 

Protected Member Functions

virtual AnyMap getMeta () const
 Retrieve meta data. More...
 
virtual void setMeta (const AnyMap &meta)
 Retrieve meta data. More...
 

Protected Attributes

shared_ptr< vector< double > > m_state
 data pointer shared from OneDim More...
 
double m_rdt = 0.0
 
size_t m_nv = 0
 
size_t m_points
 Number of grid points. More...
 
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
 
OneDimm_container = nullptr
 
size_t m_index
 
size_t m_iloc = 0
 Starting location within the solution vector for unknowns that correspond to this domain. More...
 
size_t m_jstart = 0
 
Domain1Dm_left = nullptr
 
Domain1Dm_right = nullptr
 
string m_id
 Identity tag for the domain. More...
 
unique_ptr< Refinerm_refiner
 
vector< string > m_name
 
int m_bw = -1
 
bool m_force_full_update = false
 
shared_ptr< Solutionm_solution
 Composite thermo/kinetics/transport handler. More...
 

Constructor & Destructor Documentation

◆ Domain1D()

Domain1D ( size_t  nv = 1,
size_t  points = 1,
double  time = 0.0 
)

Constructor.

Parameters
nvNumber of variables at each grid point.
pointsNumber of grid points.
time(unused)

Definition at line 17 of file Domain1D.cpp.

Member Function Documentation

◆ domainType()

virtual string domainType ( ) const
inlinevirtual

Domain type flag.

Since
Starting in Cantera 3.1, the return type is a string.

Reimplemented in StFlow, IonFlow, ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, Inlet1D, and Boundary1D.

Definition at line 44 of file Domain1D.h.

◆ type()

string type ( ) const
inline

String indicating the domain implemented.

Since
New in Cantera 3.0.
Deprecated:
Transitional method. Use domainType() instead.

Definition at line 49 of file Domain1D.h.

◆ domainIndex()

size_t domainIndex ( )
inline

The left-to-right location of this domain.

Definition at line 52 of file Domain1D.h.

◆ isConnector()

virtual bool isConnector ( )
inlinevirtual

True if the domain is a connector domain.

Reimplemented in Boundary1D.

Definition at line 57 of file Domain1D.h.

◆ setSolution()

void setSolution ( shared_ptr< Solution sol)
inline

Set the solution manager.

Since
New in Cantera 3.0.

Definition at line 63 of file Domain1D.h.

◆ setKinetics()

virtual void setKinetics ( shared_ptr< Kinetics kin)
inlinevirtual

Set the kinetics manager.

Since
New in Cantera 3.0.

Reimplemented in StFlow, and ReactingSurf1D.

Definition at line 69 of file Domain1D.h.

◆ setTransport()

virtual void setTransport ( shared_ptr< Transport trans)
inlinevirtual

Set transport model to existing instance.

Since
New in Cantera 3.0.

Reimplemented in StFlow.

Definition at line 75 of file Domain1D.h.

◆ container()

const OneDim& container ( ) const
inline

The container holding this domain.

Definition at line 80 of file Domain1D.h.

◆ setContainer()

void setContainer ( OneDim c,
size_t  index 
)
inline

Specify the container object for this domain, and the position of this domain in the list.

Definition at line 86 of file Domain1D.h.

◆ setBandwidth()

void setBandwidth ( int  bw = -1)
inline

Set the Jacobian bandwidth. See the discussion of method bandwidth().

Definition at line 92 of file Domain1D.h.

◆ bandwidth()

size_t bandwidth ( )
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 111 of file Domain1D.h.

◆ init()

virtual void init ( )
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 Boundary1D.

Definition at line 120 of file Domain1D.h.

◆ resetBadValues()

virtual void resetBadValues ( double *  xg)
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 StFlow, and ReactingSurf1D.

Definition at line 130 of file Domain1D.h.

◆ resize()

void resize ( size_t  nv,
size_t  np 
)
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, and IonFlow.

Definition at line 26 of file Domain1D.cpp.

◆ refiner()

Refiner& refiner ( )
inline

Return a reference to the grid refiner.

Definition at line 140 of file Domain1D.h.

◆ nComponents()

size_t nComponents ( ) const
inline

Number of components at each grid point.

Definition at line 145 of file Domain1D.h.

◆ checkComponentIndex()

void checkComponentIndex ( size_t  n) const
inline

Check that the specified component index is in range.

Throws an exception if n is greater than nComponents()-1

Definition at line 151 of file Domain1D.h.

◆ checkComponentArraySize()

void checkComponentArraySize ( size_t  nn) const
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 160 of file Domain1D.h.

◆ nPoints()

size_t nPoints ( ) const
inline

Number of grid points in this domain.

Definition at line 167 of file Domain1D.h.

◆ checkPointIndex()

void checkPointIndex ( size_t  n) const
inline

Check that the specified point index is in range.

Throws an exception if n is greater than nPoints()-1

Definition at line 173 of file Domain1D.h.

◆ checkPointArraySize()

void checkPointArraySize ( size_t  nn) const
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 182 of file Domain1D.h.

◆ componentName()

string componentName ( size_t  n) const
virtual

Name of the nth component. May be overloaded.

Reimplemented in StFlow, and ReactingSurf1D.

Definition at line 49 of file Domain1D.cpp.

◆ componentIndex()

size_t componentIndex ( const string &  name) const
virtual

index of component with name name.

Reimplemented in StFlow.

Definition at line 58 of file Domain1D.cpp.

◆ setTransientTolerances()

void setTransientTolerances ( double  rtol,
double  atol,
size_t  n = npos 
)

Set tolerances for time-stepping mode.

Parameters
rtolRelative tolerance
atolAbsolute tolerance
ncomponent index these tolerances apply to. If set to -1 (the default), these tolerances will be applied to all solution components.

Definition at line 69 of file Domain1D.cpp.

◆ setSteadyTolerances()

void setSteadyTolerances ( double  rtol,
double  atol,
size_t  n = npos 
)

Set tolerances for steady-state mode.

Parameters
rtolRelative tolerance
atolAbsolute tolerance
ncomponent index these tolerances apply to. If set to -1 (the default), these tolerances will be applied to all solution components.

Definition at line 82 of file Domain1D.cpp.

◆ rtol()

double rtol ( size_t  n)
inline

Relative tolerance of the nth component.

Definition at line 224 of file Domain1D.h.

◆ atol()

double atol ( size_t  n)
inline

Absolute tolerance of the nth component.

Definition at line 229 of file Domain1D.h.

◆ steady_rtol()

double steady_rtol ( size_t  n)
inline

Steady relative tolerance of the nth component.

Definition at line 234 of file Domain1D.h.

◆ steady_atol()

double steady_atol ( size_t  n)
inline

Steady absolute tolerance of the nth component.

Definition at line 239 of file Domain1D.h.

◆ transient_rtol()

double transient_rtol ( size_t  n)
inline

Transient relative tolerance of the nth component.

Definition at line 244 of file Domain1D.h.

◆ transient_atol()

double transient_atol ( size_t  n)
inline

Transient absolute tolerance of the nth component.

Definition at line 249 of file Domain1D.h.

◆ upperBound()

double upperBound ( size_t  n) const
inline

Upper bound on the nth component.

Definition at line 254 of file Domain1D.h.

◆ lowerBound()

double lowerBound ( size_t  n) const
inline

Lower bound on the nth component.

Definition at line 259 of file Domain1D.h.

◆ initTimeInteg()

void initTimeInteg ( double  dt,
const double *  x0 
)
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 267 of file Domain1D.h.

◆ setSteadyMode()

void setSteadyMode ( )
inline

Prepare to solve the steady-state problem.

Set the internally-stored reciprocal of the time step to 0.0

Definition at line 276 of file Domain1D.h.

◆ steady()

bool steady ( )
inline

True if in steady-state mode.

Definition at line 281 of file Domain1D.h.

◆ transient()

bool transient ( )
inline

True if not in steady-state mode.

Definition at line 286 of file Domain1D.h.

◆ needJacUpdate()

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 95 of file Domain1D.cpp.

◆ eval()

virtual void eval ( size_t  j,
double *  x,
double *  r,
integer *  mask,
double  rdt = 0.0 
)
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.

Parameters
jGrid point at which to update the residual
[in]xState vector
[out]rresidual vector
[out]maskBoolean mask indicating whether each solution component has a time derivative (1) or not (0).
[in]rdtReciprocal of the timestep (rdt=0 implies steady- state.)

Reimplemented in StFlow, ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, and Inlet1D.

Definition at line 310 of file Domain1D.h.

◆ asArray()

virtual shared_ptr<SolutionArray> asArray ( const double *  soln) const
inlinevirtual

Save the state of this domain as a SolutionArray.

Parameters
solnlocal solution vector for this domain
Todo:
Despite the method's name, data are copied; the intent is to access data directly in future revisions, where a non-const version will be implemented.
Since
New in Cantera 3.0.

Reimplemented in StFlow, ReactingSurf1D, Surf1D, OutletRes1D, Outlet1D, Symm1D, Empty1D, and Inlet1D.

Definition at line 331 of file Domain1D.h.

◆ toArray()

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.

Parameters
normalizeIf true, normalize concentrations (default=false)
Since
New in Cantera 3.0.

Definition at line 131 of file Domain1D.cpp.

◆ fromArray() [1/2]

virtual void fromArray ( SolutionArray arr,
double *  soln 
)
inlinevirtual

Restore the solution for this domain from a SolutionArray.

Parameters
[in]arrSolutionArray defining the state of this domain
[out]solnValue of the solution vector, local to this domain
Since
New in Cantera 3.0.

Reimplemented in StFlow, ReactingSurf1D, Surf1D, OutletRes1D, Inlet1D, and Boundary1D.

Definition at line 352 of file Domain1D.h.

◆ fromArray() [2/2]

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.

Parameters
arrSolutionArray defining the state of this domain
Since
New in Cantera 3.0.

Definition at line 143 of file Domain1D.cpp.

◆ solution()

shared_ptr<Solution> solution ( ) const
inline

Return thermo/kinetics/transport manager used in the domain.

Since
New in Cantera 3.0.

Definition at line 366 of file Domain1D.h.

◆ locate()

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 187 of file Domain1D.cpp.

◆ loc()

virtual size_t loc ( size_t  j = 0) const
inlinevirtual

Location of the start of the local solution vector in the global solution vector,.

Definition at line 384 of file Domain1D.h.

◆ firstPoint()

size_t firstPoint ( ) const
inline

The index of the first (that is, left-most) grid point belonging to this domain.

Definition at line 392 of file Domain1D.h.

◆ lastPoint()

size_t lastPoint ( ) const
inline

The index of the last (that is, right-most) grid point belonging to this domain.

Definition at line 400 of file Domain1D.h.

◆ linkLeft()

void linkLeft ( Domain1D left)
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 408 of file Domain1D.h.

◆ linkRight()

void linkRight ( Domain1D right)
inline

Set the right neighbor to domain 'right.'.

Definition at line 417 of file Domain1D.h.

◆ append()

void append ( Domain1D right)
inline

Append domain 'right' to this one, and update all links.

Definition at line 425 of file Domain1D.h.

◆ left()

Domain1D* left ( ) const
inline

Return a pointer to the left neighbor.

Definition at line 431 of file Domain1D.h.

◆ right()

Domain1D* right ( ) const
inline

Return a pointer to the right neighbor.

Definition at line 436 of file Domain1D.h.

◆ prevSoln()

double prevSoln ( size_t  n,
size_t  j 
) const
inline

Value of component n at point j in the previous solution.

Definition at line 441 of file Domain1D.h.

◆ setID()

void setID ( const string &  s)
inline

Specify an identifying tag for this domain.

Definition at line 446 of file Domain1D.h.

◆ show() [1/2]

virtual void show ( std::ostream &  s,
const double *  x 
)
inlinevirtual

Print the solution.

Reimplemented in Surf1D.

Definition at line 459 of file Domain1D.h.

◆ show() [2/2]

void show ( const double *  x)
virtual

Print the solution.

Reimplemented in StFlow, ReactingSurf1D, Surf1D, OutletRes1D, Empty1D, and Inlet1D.

Definition at line 217 of file Domain1D.cpp.

◆ setupGrid()

void setupGrid ( size_t  n,
const double *  z 
)
virtual

called to set up initial grid, and after grid refinement

Reimplemented in StFlow, and Boundary1D.

Definition at line 207 of file Domain1D.cpp.

◆ _getInitialSoln()

void _getInitialSoln ( double *  x)
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 StFlow, and ReactingSurf1D.

Definition at line 266 of file Domain1D.cpp.

◆ initialValue()

double initialValue ( size_t  n,
size_t  j 
)
virtual

Initial value of solution component n at grid point j.

Definition at line 275 of file Domain1D.cpp.

◆ _finalize()

virtual void _finalize ( const double *  x)
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 StFlow, IonFlow, and ReactingSurf1D.

Definition at line 509 of file Domain1D.h.

◆ forceFullUpdate()

void forceFullUpdate ( bool  update)
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 517 of file Domain1D.h.

◆ setData()

void setData ( shared_ptr< vector< double >> &  data)
inline

Set shared data pointer.

Definition at line 522 of file Domain1D.h.

◆ getMeta()

AnyMap getMeta ( ) const
protectedvirtual

Retrieve meta data.

Reimplemented in StFlow.

Definition at line 103 of file Domain1D.cpp.

◆ setMeta()

void setMeta ( const AnyMap meta)
protectedvirtual

Retrieve meta data.

Reimplemented in StFlow.

Definition at line 155 of file Domain1D.cpp.

Member Data Documentation

◆ m_state

shared_ptr<vector<double> > m_state
protected

data pointer shared from OneDim

Definition at line 533 of file Domain1D.h.

◆ m_points

size_t m_points
protected

Number of grid points.

Definition at line 537 of file Domain1D.h.

◆ m_iloc

size_t m_iloc = 0
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 552 of file Domain1D.h.

◆ m_id

string m_id
protected

Identity tag for the domain.

Definition at line 560 of file Domain1D.h.

◆ m_solution

shared_ptr<Solution> m_solution
protected

Composite thermo/kinetics/transport handler.

Definition at line 567 of file Domain1D.h.


The documentation for this class was generated from the following files: