Processing math: 100%
Cantera  3.2.0a1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AdaptivePreconditioner Class Reference

AdaptivePreconditioner a preconditioner designed for use with large mechanisms that leverages sparse solvers. More...

#include <AdaptivePreconditioner.h>

Inheritance diagram for AdaptivePreconditioner:
[legend]

Detailed Description

AdaptivePreconditioner a preconditioner designed for use with large mechanisms that leverages sparse solvers.

It does this by pruning the preconditioner by a threshold value. It also neglects pressure dependence and third body contributions in its formation and has a finite difference approximation for temperature.

Definition at line 23 of file AdaptivePreconditioner.h.

Public Member Functions

void initialize (size_t networkSize) override
 Called during setup for any processes that need to be completed prior to setup functions used in sundials.
 
const string type () const override
 Derived type, corresponding to names registered with SystemJacobianFactory.
 
void setup () override
 Perform preconditioner specific post-reactor setup operations such as factorize.
 
void factorize () override
 Factorize the system matrix.
 
void solve (const size_t stateSize, double *rhs_vector, double *output) override
 Solve a linear system using the system matrix M
 
void stateAdjustment (vector< double > &state) override
 Adjust the state vector based on the preconditioner, e.g., Adaptive preconditioning uses a strictly positive composition when preconditioning which is handled by this function.
 
int info () const override
 Get latest status of linear solver.
 
void prunePreconditioner ()
 Prune preconditioner elements.
 
double threshold ()
 Get the threshold value for setting elements.
 
double ilutFillFactor ()
 Get ILUT fill factor.
 
double ilutDropTol ()
 Get ILUT drop tolerance.
 
void setThreshold (double threshold)
 Set the threshold value to compare elements against.
 
void setIlutDropTol (double droptol)
 Set drop tolerance for ILUT.
 
void setIlutFillFactor (int fillFactor)
 Set the fill factor for ILUT solver.
 
- Public Member Functions inherited from EigenSparseJacobian
void initialize (size_t networkSize) override
 Called during setup for any processes that need to be completed prior to setup functions used in sundials.
 
void reset () override
 Reset parameters as needed.
 
void setValue (size_t row, size_t col, double value) override
 Set a value at the specified row and column of the jacobian triplet vector.
 
void updatePreconditioner () override
 Transform Jacobian vector and write into preconditioner, P = (I - gamma * J)
 
void updateTransient (double rdt, int *mask) override
 Update the diagonal terms in the Jacobian by using the transient mask \alpha .
 
Eigen::SparseMatrix< double > jacobian ()
 Return underlying Jacobian matrix.
 
Eigen::SparseMatrix< double > matrix ()
 Return the internal preconditioner matrix.
 
void printPreconditioner () override
 Print preconditioner contents.
 
void printJacobian ()
 Print jacobian contents.
 
- Public Member Functions inherited from SystemJacobian
virtual const string type () const =0
 Derived type, corresponding to names registered with SystemJacobianFactory.
 
virtual void setValue (size_t row, size_t col, double value)
 Set a value at the specified row and column of the jacobian triplet vector.
 
virtual void stateAdjustment (vector< double > &state)
 Adjust the state vector based on the preconditioner, e.g., Adaptive preconditioning uses a strictly positive composition when preconditioning which is handled by this function.
 
string preconditionerSide () const
 Get preconditioner application side for CVODES.
 
virtual void setPreconditionerSide (const string &preconSide)
 For iterative solvers, set the side where the preconditioner is applied.
 
virtual void updatePreconditioner ()
 Transform Jacobian vector and write into preconditioner, P = (I - gamma * J)
 
virtual void updateTransient (double rdt, int *mask)
 Update the diagonal terms in the Jacobian by using the transient mask \alpha .
 
virtual void solve (const size_t stateSize, double *rhs_vector, double *output)
 Solve a linear system using the system matrix M
 
virtual void setup ()
 Perform preconditioner specific post-reactor setup operations such as factorize.
 
virtual void reset ()
 Reset parameters as needed.
 
virtual void initialize (size_t networkSize)
 Called during setup for any processes that need to be completed prior to setup functions used in sundials.
 
virtual void setBandwidth (size_t bw)
 Used to provide system bandwidth for implementations that use banded matrix storage.
 
virtual void printPreconditioner ()
 Print preconditioner contents.
 
virtual void setGamma (double gamma)
 Set gamma used in preconditioning.
 
virtual double gamma ()
 Get gamma used in preconditioning.
 
virtual void setAbsoluteTolerance (double atol)
 Set the absolute tolerance in the solver outside of the network initialization.
 
virtual int info () const
 Get latest status of linear solver.
 
double elapsedTime () const
 Elapsed CPU time spent computing the Jacobian elements.
 
void updateElapsed (double evalTime)
 Increase the elapsed time by the specified time.
 
int nEvals () const
 Number of Jacobian evaluations.
 
void incrementEvals ()
 Increment the number of times the Jacobian has been evaluated.
 
int age () const
 Number of times 'incrementAge' has been called since the last evaluation.
 
void incrementAge ()
 Increment the Jacobian age.
 
void setAge (int age)
 Set the Jacobian age.
 
void clearStats ()
 Clear collected stats about number of Jacobian evaluations, CPU time spent on Jacobian updates, and the number of Newton steps that have been taken since updating the Jacobian.
 

Protected Attributes

double m_fill_factor = 0
 ILUT fill factor.
 
double m_drop_tol = 0
 ILUT drop tolerance.
 
Eigen::IncompleteLUT< double > m_solver
 Solver used in solving the linear system.
 
double m_threshold = 0.0
 Minimum value a non-diagonal element must be to be included in the preconditioner.
 
double m_prune_precon = true
 Bool set whether to prune the matrix or not.
 
- Protected Attributes inherited from EigenSparseJacobian
vector< Eigen::Triplet< double > > m_jac_trips
 Vector of triples representing the jacobian used in preconditioning.
 
Eigen::SparseMatrix< double > m_identity
 Storage of appropriately sized identity matrix for making the preconditioner.
 
Eigen::SparseMatrix< double > m_matrix
 Container that is the sparse preconditioner.
 
- Protected Attributes inherited from SystemJacobian
size_t m_dim
 Dimension of the system.
 
double m_gamma = 1.0
 gamma value used in M = I - gamma*J
 
bool m_init = false
 bool saying whether or not the system is initialized
 
double m_atol = 0
 Absolute tolerance of the ODE solver.
 
double m_elapsed = 0.0
 Elapsed CPU time taken to compute the Jacobian.
 
int m_nevals = 0
 Number of Jacobian evaluations.
 
int m_age = 100000
 Age of the Jacobian (times incrementAge() has been called)
 
string m_precon_side = "none"
 For iterative solvers, side of the system to apply the preconditioner on.
 

Additional Inherited Members

virtual void factorize ()
 Factorize the system matrix.
 

Constructor & Destructor Documentation

◆ AdaptivePreconditioner()

Definition at line 12 of file AdaptivePreconditioner.cpp.

Member Function Documentation

◆ initialize()

void initialize ( size_t  networkSize)
overridevirtual

Called during setup for any processes that need to be completed prior to setup functions used in sundials.

Parameters
networkSizethe number of variables in the associated reactor network

Reimplemented from SystemJacobian.

Definition at line 24 of file AdaptivePreconditioner.cpp.

◆ type()

const string type ( ) const
inlineoverridevirtual

Derived type, corresponding to names registered with SystemJacobianFactory.

Implements SystemJacobian.

Definition at line 29 of file AdaptivePreconditioner.h.

◆ setup()

void setup ( )
overridevirtual

Perform preconditioner specific post-reactor setup operations such as factorize.

Deprecated:
To be removed after Cantera 3.2. Use updatePreconditioner() and factorize() instead.

Reimplemented from SystemJacobian.

Definition at line 40 of file AdaptivePreconditioner.cpp.

◆ factorize()

void factorize ( )
overridevirtual

Factorize the system matrix.

This method should be called at the end of implementations of updatePreconditioner() and updateTransient().

Reimplemented from SystemJacobian.

Definition at line 48 of file AdaptivePreconditioner.cpp.

◆ solve()

void solve ( const size_t  stateSize,
double *  rhs_vector,
double *  output 
)
overridevirtual

Solve a linear system using the system matrix M

The matrix M can either be the preconditioner or the transient Jacobian matrix, depending on whether updateTransient() or updatePreconditioner() was called last.

Parameters
[in]stateSizelength of the rhs and output vectors
[in]rhs_vectorright hand side vector used in linear system
[out]outputoutput vector for solution

Reimplemented from SystemJacobian.

Definition at line 76 of file AdaptivePreconditioner.cpp.

◆ stateAdjustment()

void stateAdjustment ( vector< double > &  state)
overridevirtual

Adjust the state vector based on the preconditioner, e.g., Adaptive preconditioning uses a strictly positive composition when preconditioning which is handled by this function.

Parameters
statea vector containing the state to be updated

Reimplemented from SystemJacobian.

Definition at line 17 of file AdaptivePreconditioner.cpp.

◆ info()

int info ( ) const
inlineoverridevirtual

Get latest status of linear solver.

Zero indicates success. Meaning of non-zero values is solver dependent.

Reimplemented from SystemJacobian.

Definition at line 35 of file AdaptivePreconditioner.h.

◆ prunePreconditioner()

void prunePreconditioner ( )

Prune preconditioner elements.

Definition at line 64 of file AdaptivePreconditioner.cpp.

◆ threshold()

double threshold ( )
inline

Get the threshold value for setting elements.

Definition at line 43 of file AdaptivePreconditioner.h.

◆ ilutFillFactor()

double ilutFillFactor ( )
inline

Get ILUT fill factor.

Definition at line 46 of file AdaptivePreconditioner.h.

◆ ilutDropTol()

double ilutDropTol ( )
inline

Get ILUT drop tolerance.

Definition at line 49 of file AdaptivePreconditioner.h.

◆ setThreshold()

void setThreshold ( double  threshold)
inline

Set the threshold value to compare elements against.

Parameters
thresholddouble value used in setting by threshold

Definition at line 53 of file AdaptivePreconditioner.h.

◆ setIlutDropTol()

void setIlutDropTol ( double  droptol)
inline

Set drop tolerance for ILUT.

Parameters
droptoldouble value used in setting solver drop tolerance

Definition at line 60 of file AdaptivePreconditioner.h.

◆ setIlutFillFactor()

void setIlutFillFactor ( int  fillFactor)
inline

Set the fill factor for ILUT solver.

Parameters
fillFactorfill in factor for ILUT solver

Definition at line 67 of file AdaptivePreconditioner.h.

Member Data Documentation

◆ m_fill_factor

double m_fill_factor = 0
protected

ILUT fill factor.

Definition at line 74 of file AdaptivePreconditioner.h.

◆ m_drop_tol

double m_drop_tol = 0
protected

ILUT drop tolerance.

Definition at line 77 of file AdaptivePreconditioner.h.

◆ m_solver

Eigen::IncompleteLUT<double> m_solver
protected

Solver used in solving the linear system.

Definition at line 80 of file AdaptivePreconditioner.h.

◆ m_threshold

double m_threshold = 0.0
protected

Minimum value a non-diagonal element must be to be included in the preconditioner.

Definition at line 84 of file AdaptivePreconditioner.h.

◆ m_prune_precon

double m_prune_precon = true
protected

Bool set whether to prune the matrix or not.

Definition at line 87 of file AdaptivePreconditioner.h.


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