|
SpECTRE
v2026.06.09.01
|
Algorithms to solve linear systems of equations. More...
Namespaces | |
| namespace | LinearSolver |
| Functionality for solving linear systems of equations. | |
| namespace | LinearSolver::Tags |
| The DataBox tags associated with the linear solver. | |
| namespace | LinearSolver::InnerProductImpls |
| Implementations of LinearSolver::inner_product. | |
Classes | |
| struct | LinearSolver::cg::ConjugateGradient< Metavariables, FieldsTag, OptionsGroup, SourceTag > |
| A conjugate gradient solver for linear systems of equations \(Ax=b\) where the operator \(A\) is symmetric. More... | |
| struct | LinearSolver::gmres::Gmres< Metavariables, FieldsTag, OptionsGroup, Preconditioned, SourceTag, ArraySectionIdTag > |
| A GMRES solver for nonsymmetric linear systems of equations \(Ax=b\). More... | |
| struct | LinearSolver::Richardson::Richardson< FieldsTag, OptionsGroup, SourceTag, ArraySectionIdTag > |
| A simple Richardson scheme for solving a system of linear equations \(Ax=b\). More... | |
| struct | LinearSolver::Schwarz::Schwarz< FieldsTag, OptionsGroup, SubdomainOperator, SubdomainPreconditioners, SourceTag, ArraySectionIdTag > |
| An additive Schwarz subdomain solver for linear systems of equations \(Ax=b\). More... | |
Functions | |
| template<typename Lhs, typename Rhs> | |
| auto | LinearSolver::inner_product (const Lhs &lhs, const Rhs &rhs) |
| The local part of the Euclidean inner product on the vector space w.r.t. which the addition and scalar multiplication of both Lhs and Rhs is defined. | |
| template<typename T> | |
| double | LinearSolver::magnitude_square (const T &vector) |
| The local part of the Euclidean inner product of a vector with itself. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > rhs_in_solution_out, gsl::not_null< Matrix * > matrix_operator, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > rhs_in_solution_out, gsl::not_null< std::vector< int > * > pivots, gsl::not_null< Matrix * > matrix_operator, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > solution, gsl::not_null< Matrix * > matrix_operator, const DataVector &rhs, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > solution, gsl::not_null< std::vector< int > * > pivots, gsl::not_null< Matrix * > matrix_operator, const DataVector &rhs, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > rhs_in_solution_out, const Matrix &matrix_operator, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
| int | lapack::general_matrix_linear_solve (gsl::not_null< DataVector * > solution, const Matrix &matrix_operator, const DataVector &rhs, int number_of_rhs=0) |
| Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition. | |
Algorithms to solve linear systems of equations.
In a way, the linear solver is for elliptic systems what time stepping is for the evolution code. This is because the DG scheme for an elliptic system reduces to a linear system of equations of the type \(Ax=b\), where \(A\) is a global matrix representing the DG discretization of the problem. Since this is one equation for each node in the computational domain it becomes unfeasible to numerically invert the global matrix \(A\). Instead, we solve the problem iteratively so that we never need to construct \(A\) globally but only need \(Ax\) that can be evaluated locally by virtue of the DG formulation. This action of the operator is what we have to supply in each step of the iterative algorithms implemented here. It is where most of the computational cost goes and usually involves computing a volume contribution for each element and communicating fluxes with neighboring elements. Since the iterative algorithms typically scale badly with increasing grid size, a preconditioner \(P\) is needed in order to make \(P^{-1}A\) easier to invert.
In the iterative algorithms we usually don't work with the physical field \(x\) directly. Instead we need to apply the operator to an internal variable defined by the respective algorithm. This variable is exposed as the LinearSolver::Tags::Operand prefix, and the algorithm expects that the computed operator action is written into db::add_tag_prefix<LinearSolver::Tags::OperatorAppliedTo, LinearSolver::Tags::Operand<...>> in each step.
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | rhs_in_solution_out, |
| const Matrix & | matrix_operator, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | rhs_in_solution_out, |
| gsl::not_null< Matrix * > | matrix_operator, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | rhs_in_solution_out, |
| gsl::not_null< std::vector< int > * > | pivots, | ||
| gsl::not_null< Matrix * > | matrix_operator, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | solution, |
| const Matrix & | matrix_operator, | ||
| const DataVector & | rhs, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | solution, |
| gsl::not_null< Matrix * > | matrix_operator, | ||
| const DataVector & | rhs, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| int lapack::general_matrix_linear_solve | ( | gsl::not_null< DataVector * > | solution, |
| gsl::not_null< std::vector< int > * > | pivots, | ||
| gsl::not_null< Matrix * > | matrix_operator, | ||
| const DataVector & | rhs, | ||
| int | number_of_rhs = 0 ) |
Wrapper for LAPACK dgesv, which solves the general linear equation \(A x = b\) by LUP (Lower-triangular, upper-triangular, and permutation) decomposition.
Several interfaces are provided with combinations of input parameters due to the versatility of the LAPACK utility.
The function return int is the value provided by the INFO field of the LAPACK call. It is 0 for a successful linear solve, and nonzero values code for types of failures of the algorithm. See LAPACK documentation for further details about dgesv: http://www.netlib.org/lapack/
| auto LinearSolver::inner_product | ( | const Lhs & | lhs, |
| const Rhs & | rhs ) |
The local part of the Euclidean inner product on the vector space w.r.t. which the addition and scalar multiplication of both Lhs and Rhs is defined.
The linear solver works under the following assumptions:
lhs and rhs can each be interpreted as the local chunk of a vector of the same vector space \(V\). Local means there are vectors \(q, p\in V\) such that lhs and rhs represent the components of these vectors w.r.t. a subset \(B_i\) of a basis \(B\subset V\).In practice this means that the full vectors \(p\) and \(q\) can be distributed on many elements, where each only holds local chunks lhs and rhs of the components. Scalar multiplication and addition can be performed locally as expected, but computing the full inner product requires a global reduction over all elements that sums their local inner_products.
| double LinearSolver::magnitude_square | ( | const T & | vector | ) |
The local part of the Euclidean inner product of a vector with itself.