Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
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
9
#include "
cantera/numerics/SystemJacobian.h
"
10
#include "cantera/numerics/eigen_sparse.h"
11
12
namespace
Cantera
13
{
14
15
//! System Jacobians that use Eigen sparse matrices for storage
16
class
EigenSparseJacobian :
public
SystemJacobian
17
{
18
public
:
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, span<const 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
() {
37
updatePreconditioner
();
38
return
m_matrix
;
39
}
40
41
void
printPreconditioner
()
override
;
42
43
//! Print jacobian contents
44
void
printJacobian
();
45
46
protected
:
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
SystemJacobian.h
Declarations for class SystemJacobian.
Cantera::EigenSparseJacobian::matrix
Eigen::SparseMatrix< double > matrix()
Return the internal preconditioner matrix.
Definition
EigenSparseJacobian.h:36
Cantera::EigenSparseJacobian::updateTransient
void updateTransient(double rdt, span< const int > mask) override
Update the diagonal terms in the Jacobian by using the transient mask .
Definition
EigenSparseJacobian.cpp:51
Cantera::EigenSparseJacobian::setValue
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.
Definition
EigenSparseJacobian.cpp:36
Cantera::EigenSparseJacobian::initialize
void initialize(size_t networkSize) override
Called during setup for any processes that need to be completed prior to setup functions used in sund...
Definition
EigenSparseJacobian.cpp:12
Cantera::EigenSparseJacobian::m_jac_trips
vector< Eigen::Triplet< double > > m_jac_trips
Vector of triples representing the jacobian used in preconditioning.
Definition
EigenSparseJacobian.h:48
Cantera::EigenSparseJacobian::m_identity
Eigen::SparseMatrix< double > m_identity
Storage of appropriately sized identity matrix for making the preconditioner.
Definition
EigenSparseJacobian.h:51
Cantera::EigenSparseJacobian::printPreconditioner
void printPreconditioner() override
Print preconditioner contents.
Definition
EigenSparseJacobian.cpp:68
Cantera::EigenSparseJacobian::updatePreconditioner
void updatePreconditioner() override
Transform Jacobian vector and write into preconditioner, P = (I - gamma * J).
Definition
EigenSparseJacobian.cpp:41
Cantera::EigenSparseJacobian::setFromTriplets
void setFromTriplets(const vector< Eigen::Triplet< double > > &trips)
Set all Jacobian elements. Replaces the existing elements.
Definition
EigenSparseJacobian.h:27
Cantera::EigenSparseJacobian::printJacobian
void printJacobian()
Print jacobian contents.
Definition
EigenSparseJacobian.cpp:75
Cantera::EigenSparseJacobian::reset
void reset() override
Reset parameters as needed.
Definition
EigenSparseJacobian.cpp:30
Cantera::EigenSparseJacobian::m_matrix
Eigen::SparseMatrix< double > m_matrix
Container that is the sparse preconditioner.
Definition
EigenSparseJacobian.h:54
Cantera::EigenSparseJacobian::jacobian
Eigen::SparseMatrix< double > jacobian()
Return underlying Jacobian matrix.
Definition
EigenSparseJacobian.cpp:61
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
include
cantera
numerics
EigenSparseJacobian.h
Generated by
1.17.0