Template Class LinearSolver

Inheritance Relationships

Derived Type

Class Documentation

template<class ScalarT, typename IdxT>
class LinearSolver

Interface for linear solvers used by GridKit integrators, including Rosenbrock.

Subclassed by GridKit::LinearAlgebra::ResolveSystemSolver< ScalarT, IdxT >

Public Functions

virtual int configureSolver(GridKit::LinearAlgebra::CsrMatrix<RealT, IdxT> &matrix) = 0

Configure the solver by analyzing the given matrix. The sparsity pattern of the given matrix must be set, and future calls to other methods will use this sparsity pattern, as well as the data pointer of the given matrix.

Parameters:

matrix – The matrix to configure the solver with.

Returns:

int An error code, or 0 if none.

virtual int setupSolver(bool reuse_factors = false) = 0

Setup the solver with matrix data.

Parameters:

reuse_factors – If true, factors from a previous call to setupSolver() are reused.

Pre:

configureSolver() must be called first and every time the sparsity pattern of the matrix changes.

Pre:

If reuse_factors is true, then setupSolver must have been called once before with the same sparsity pattern.

Returns:

int An error code, or 0 if none.

virtual int solve(GridKit::LinearAlgebra::Vector<ScalarT, IdxT> &rhs, GridKit::LinearAlgebra::Vector<ScalarT, IdxT> &lhs) = 0

Perform a linear solve using the configured matrix.

Todo:

The data of the rhs parameter doesn’t change, but we can’t mark as cosntant because ReSolve currently requires a non-const pointer for vectors, even if it will only read from that vector. In the future this might change, so this can be updated to be const.

Parameters:
  • rhs – The right-hand-side vector (input). No data is changed.

  • lhs – The left-hand-side vector (output).

Pre:

setupSolver must be called first and every time the data of the matrix changes.

Returns:

int An error code, or 0 if none.