Cantera  4.0.0a1
Loading...
Searching...
No Matches
EigenSparseJacobian.h
Go to the documentation of this file.
1//! @file EigenSparseJacobian.h
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
6#ifndef EIGENSPARSEJACOBIAN_H
7#define EIGENSPARSEJACOBIAN_H
8
10#include "cantera/numerics/eigen_sparse.h"
11
12namespace Cantera
13{
14
15//! System Jacobians that use Eigen sparse matrices for storage
17{
18public:
19 EigenSparseJacobian() = default;
20 void initialize(size_t networkSize) override;
21 void reset() override;
22 void setValue(size_t row, size_t col, double value) override;
23 void updatePreconditioner() override;
24 void updateTransient(double rdt, int* mask) override;
25
26 //! Set all Jacobian elements. Replaces the existing elements.
27 void setFromTriplets(const vector<Eigen::Triplet<double>>& trips) {
28 m_jac_trips = trips;
29 }
30
31 //! Return underlying Jacobian matrix
32 //! @ingroup derivGroup
33 Eigen::SparseMatrix<double> jacobian();
34
35 //! Return the internal preconditioner matrix
36 Eigen::SparseMatrix<double> matrix() {
38 return m_matrix;
39 }
40
41 void printPreconditioner() override;
42
43 //! Print jacobian contents
44 void printJacobian();
45
46protected:
47 //! Vector of triples representing the jacobian used in preconditioning
48 vector<Eigen::Triplet<double>> m_jac_trips;
49
50 //! Storage of appropriately sized identity matrix for making the preconditioner
51 Eigen::SparseMatrix<double> m_identity;
52
53 //! Container that is the sparse preconditioner
54 Eigen::SparseMatrix<double> m_matrix;
55};
56
57}
58
59#endif
Declarations for class SystemJacobian.
System Jacobians that use Eigen sparse matrices for storage.
Eigen::SparseMatrix< double > matrix()
Return the internal preconditioner matrix.
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 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.
Eigen::SparseMatrix< double > m_identity
Storage of appropriately sized identity matrix for making the preconditioner.
void printPreconditioner() override
Print preconditioner contents.
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 .
void setFromTriplets(const vector< Eigen::Triplet< double > > &trips)
Set all Jacobian elements. Replaces the existing elements.
void printJacobian()
Print jacobian contents.
void reset() override
Reset parameters as needed.
Eigen::SparseMatrix< double > m_matrix
Container that is the sparse preconditioner.
Abstract base class representing Jacobian matrices and preconditioners used in nonlinear solvers.
Eigen::SparseMatrix< double > jacobian()
Return underlying Jacobian matrix.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595