Loading [MathJax]/extensions/tex2jax.js
Cantera  3.2.0a1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EigenSparseDirectJacobian.cpp
Go to the documentation of this file.
1//! @file EigenSparseDirectJacobian.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
7#include "cantera/numerics/eigen_dense.h"
8
9namespace Cantera
10{
11
13{
14 m_matrix.makeCompressed();
15 // analyze and factorize
16 m_solver.compute(m_matrix);
17 // check for errors
18 if (m_solver.info() != Eigen::Success) {
19 throw CanteraError("EigenSparseDirectJacobian::factorize",
20 "error code: {}", static_cast<int>(m_solver.info()));
21 }
22}
23
24void EigenSparseDirectJacobian::solve(const size_t stateSize, double* b, double* x)
25{
26 MappedVector(x, m_dim) = m_solver.solve(MappedVector(b, m_dim));
27 // check for errors
28 if (m_solver.info() != Eigen::Success) {
29 throw CanteraError("EigenSparseDirectJacobian::solve",
30 "error code: {}", static_cast<int>(m_solver.info()));
31 }
32}
33
34}
Base class for exceptions thrown by Cantera classes.
void solve(const size_t stateSize, double *rhs_vector, double *output) override
Solve a linear system using the system matrix M
void factorize() override
Factorize the system matrix.
Eigen::SparseMatrix< double > m_matrix
Container that is the sparse preconditioner.
size_t m_dim
Dimension of the system.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595