12 AdaptivePreconditioner::AdaptivePreconditioner()
14 setPreconditionerSide(
"right");
19 m_jac_trips.emplace_back(
static_cast<int>(row),
static_cast<int>(col), value);
24 for (
size_t i = 0; i < state.size(); i++) {
25 state[i] = std::max(state[i],
m_atol);
66 if (
m_solver.info() != Eigen::Success) {
68 "error code: {}",
static_cast<int>(
m_solver.info()));
87 for (Eigen::SparseMatrix<double>::InnerIterator it(
m_precon_matrix, k); it;
89 if (std::abs(it.value()) <
m_threshold && it.row() != it.col()) {
100 Eigen::Map<Eigen::VectorXd> bVector(rhs_vector, stateSize);
101 Eigen::Map<Eigen::VectorXd> xVector(output, stateSize);
104 if (
m_solver.info() != Eigen::Success) {
106 "error code: {}",
static_cast<int>(
m_solver.info()));
111 std::stringstream ss;
112 Eigen::IOFormat HeavyFmt(Eigen::FullPrecision, 0,
", ",
";\n",
"[",
"]",
"[",
"]");
118 std::stringstream ss;
Declarations for the class AdaptivePreconditioner which is a child class of PreconditionerBase for pr...
Eigen::IncompleteLUT< double > m_solver
Solver used in solving the linear system.
void setIlutDropTol(double droptol)
Set drop tolerance for ILUT.
double m_drop_tol
ILUT drop tolerance.
void solve(const size_t stateSize, double *rhs_vector, double *output) override
Solve a linear system Ax=b where A is the preconditioner.
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.
double m_prune_precon
Bool set whether to prune the matrix or not.
double m_threshold
Minimum value a non-diagonal element must be to be included in the preconditioner.
void initialize(size_t networkSize) override
Called during setup for any processes that need to be completed prior to setup functions used in sund...
vector< Eigen::Triplet< double > > m_jac_trips
Vector of triples representing the jacobian used in preconditioning.
void setIlutFillFactor(int fillFactor)
Set the fill factor for ILUT solver.
Eigen::SparseMatrix< double > m_identity
Storage of appropriately sized identity matrix for making the preconditioner.
void printPreconditioner() override
Print preconditioner contents.
void setup() override
Perform preconditioner specific post-reactor setup operations such as factorize.
void stateAdjustment(vector< double > &state) override
Adjust the state vector based on the preconditioner, e.g., Adaptive preconditioning uses a strictly p...
void updatePreconditioner() override
Transform Jacobian vector and write into preconditioner, P = (I - gamma * J)
void prunePreconditioner()
Prune preconditioner elements.
void printJacobian()
Print jacobian contents.
Eigen::SparseMatrix< double > m_precon_matrix
Container that is the sparse preconditioner.
Base class for exceptions thrown by Cantera classes.
size_t m_dim
Dimension of the preconditioner.
double m_gamma
gamma value used in M = I - gamma*J
bool m_init
bool saying whether or not the preconditioner is initialized
double m_atol
Absolute tolerance of the ODE solver.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Eigen::SparseMatrix< double > jacobian()
Return semi-analytical Jacobian of an AdaptivePreconditioner object.
void use_legacy_rate_constants(bool legacy)
Set definition used for rate constant calculation.
void writelog(const string &fmt, const Args &... args)
Write a formatted message to the screen.
Namespace for the Cantera kernel.