![]() |
Documentation 6b54b78464
|
Main class for defining block-compressed-row-storage sparse matrices. More...
#include <CSysMatrix.hpp>
Public Member Functions | |
| CSysMatrix () | |
| Constructor of the class. | |
| ~CSysMatrix () | |
| Destructor of the class. | |
| void | Initialize (unsigned long npoint, unsigned long npointdomain, unsigned short nvar, unsigned short neqn, bool EdgeConnect, CGeometry *geometry, const CConfig *config, bool needTranspPtr=false, bool allow_quant=false, std::optional< unsigned short > override_prec=std::nullopt) |
| Initializes the sparse matrix. | |
| void | QuantizeDiagonalBlocks () |
| Compresses off-diagonal blocks into quantized form for use with USE_QUANTIZATION. | |
| void | SetValZero () |
| Sets to zero all the entries of the sparse matrix. | |
| void | SetValDiagonalZero () |
| Sets to zero all the block diagonal entries of the sparse matrix. | |
| void | HtDTransfer (bool trigger=true) const |
| Performs the memory copy from host to device. | |
| const ScalarType * | GetBlock (unsigned long block_i, unsigned long block_j) const |
| Get a pointer to the start of block "ij". | |
| ScalarType * | GetBlock (unsigned long block_i, unsigned long block_j) |
| Get a pointer to the start of block "ij", non-const version. | |
| CBlockView< const ScalarType > | GetBlockView (unsigned long block_i, unsigned long block_j) const |
| Read-only view of block (block_i, block_j). In Q_LU_SGS mode values are decoded on access inside CBlockView::operator()(i,j); no temporary copy is made. | |
| CBlockView< ScalarType > | GetBlockView (unsigned long block_i, unsigned long block_j) |
| template<bool Overwrite = true, class MatrixType > | |
| void | SetBlock (unsigned long block_i, unsigned long block_j, MatrixType &val_block, std::decay_t< typename MatrixType::Scalar > alpha=1.0) |
| Set the value of a scaled block in the sparse matrix. | |
| template<bool Overwrite = true, class OtherType , su2enable_if<!is_pointer< OtherType >::value > = 0> | |
| void | SetBlock (unsigned long block_i, unsigned long block_j, const OtherType *val_block, std::decay_t< OtherType > alpha=1.0) |
| template<bool Overwrite = true, class OtherType > | |
| void | SetBlock (unsigned long block_i, unsigned long block_j, const OtherType *const *val_block, std::decay_t< OtherType > alpha=1.0) |
| template<class T , class OtherType = ScalarType> | |
| void | AddBlock (unsigned long block_i, unsigned long block_j, const T &val_block, OtherType alpha=1.0) |
| Add a scaled block (in flat format) to the sparse matrix (see SetBlock). | |
| template<class T > | |
| void | SubtractBlock (unsigned long block_i, unsigned long block_j, const T &val_block) |
| Subtracts the specified block to the sparse matrix (see AddBlock). | |
| void | GetBlocks (unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, ScalarType *&bii, ScalarType *&bij, ScalarType *&bji, ScalarType *&bjj) |
| Returns the 4 blocks ii, ij, ji, jj used by "UpdateBlocks". | |
| template<bool OverwriteOffDiag = false, class MatrixType , class OtherType = ScalarType> | |
| void | UpdateBlocks (unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, const MatrixType &block_i, const MatrixType &block_j, OtherType scale=1) |
| Update 4 blocks ii, ij, ji, jj (add to i* sub from j*). | |
| template<class MatrixType > | |
| void | UpdateBlocksSub (unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, const MatrixType &block_i, const MatrixType &block_j) |
| Short-hand for the "subtractive" version (sub from i* add to j*) of UpdateBlocks. | |
| template<class MatTypeSIMD , size_t N, class I , class F = ScalarType> | |
| void | SetBlocks (simd::Array< I, N > iEdge, simd::Array< I, N > iPoint, simd::Array< I, N > jPoint, const MatTypeSIMD &block_i, const MatTypeSIMD &block_j, simd::Array< F, N > mask=1) |
| SIMD version, does the update for multiple edges and points. | |
| template<class MatrixType , class OtherType = ScalarType, bool Overwrite = true> | |
| void | SetBlocks (unsigned long iEdge, const MatrixType &block_i, const MatrixType &block_j, OtherType scale=1) |
| Sets 2 blocks ij and ji (add to i* sub from j*) associated with one edge of an FVM-type sparse pattern. | |
| template<class MatrixType , class OtherType = ScalarType> | |
| void | UpdateBlocks (unsigned long iEdge, const MatrixType &block_i, const MatrixType &block_j, OtherType scale=1) |
| Short-hand for the "additive overwrite" version of SetBlocks. | |
| template<class MatrixType > | |
| void | UpdateBlocksSub (unsigned long iEdge, const MatrixType &block_i, const MatrixType &block_j) |
| Short-hand for the "subtractive" version (sub from i* add to j*) of SetBlocks. | |
| template<class MatrixType , class OtherType = ScalarType> | |
| void | SetBlocks (unsigned long iEdge, unsigned long iPoint, unsigned long jPoint, const MatrixType &jac_ii, const MatrixType &jac_ij, const MatrixType &jac_ji, const MatrixType &jac_jj, OtherType mask=1) |
| Set the four blocks of an edge, for fluxes whose i and j contributions are independent. | |
| template<class MatrixType , class OtherType = ScalarType> | |
| void | SetOffDiagBlocks (unsigned long iEdge, const MatrixType &jac_ij, const MatrixType &jac_ji, OtherType mask=1) |
| Set the off-diagonal blocks of an edge, the diagonal being assembled elsewhere. | |
| template<class MatTypeSIMD , size_t N, class I , class F = ScalarType> | |
| void | SetBlocks (simd::Array< I, N > iEdge, const MatTypeSIMD &block_i, const MatTypeSIMD &block_j, simd::Array< F, N > mask=1) |
| SIMD version, does the update for multiple edges. | |
| template<class OtherType , bool Overwrite = true, class T = ScalarType> | |
| void | SetBlock2Diag (unsigned long block_i, const OtherType &val_block, T alpha=1.0) |
| Sets the specified block to the (i, i) subblock of the sparse matrix. Scales the input block by factor alpha. If the Overwrite parameter is false we update instead (bii += alpha*b). | |
| template<class OtherType , class T = ScalarType> | |
| void | AddBlock2Diag (unsigned long block_i, const OtherType &val_block, T alpha=1.0) |
| Non overwrite version of SetBlock2Diag, also with scaling. | |
| template<class OtherType > | |
| void | SubtractBlock2Diag (unsigned long block_i, const OtherType &val_block) |
| Short-hand to AddBlock2Diag with alpha = -1, i.e. subtracts from the current diagonal. | |
| template<class OtherType > | |
| void | AddVal2Diag (unsigned long block_i, OtherType val_matrix) |
| Adds the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure. | |
| template<class OtherType > | |
| void | AddVal2Diag (unsigned long block_i, unsigned long iVar, OtherType val) |
| Adds the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure. | |
| template<class OtherType > | |
| void | SetVal2Diag (unsigned long block_i, OtherType val_matrix) |
| Sets the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure. | |
| void | DeleteValsRowi (unsigned long block_i, unsigned long row) |
| Deletes the values of a row of the sparse matrix. | |
| template<class OtherType > | |
| void | EnforceSolutionAtNode (unsigned long node_i, const OtherType *x_i, CSysVector< OtherType > &b) |
| Modifies this matrix (A) and a rhs vector (b) such that (A^-1 * b)_i = x_i. | |
| template<class OtherType > | |
| void | EnforceZeroProjection (unsigned long node_i, const OtherType *n, CSysVector< OtherType > &b) |
| Similar to EnforceSolutionAtNode, but for 0 projection in a given direction. | |
| void | SetDiagonalAsColumnSum () |
| Sets the diagonal entries of the matrix as the sum of the blocks in the corresponding column. | |
| void | TransposeInPlace () |
| Transposes the matrix, any preconditioner that was computed may be invalid. | |
| void | MatrixMatrixAddition (ScalarType alpha, const CSysMatrix &B) |
| Add a scaled sparse matrix to "this" (axpy-type operation, A = A+alpha*B). | |
| void | MatrixVectorProduct (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Performs the product of a sparse matrix by a CSysVector. | |
| void | BuildJacobiPreconditioner () |
| Build the Jacobi preconditioner. | |
| void | ComputeJacobiPreconditioner (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Multiply CSysVector by the preconditioner. | |
| void | BuildILUPreconditioner () |
| Build the ILU preconditioner. | |
| void | ComputeILUPreconditioner (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Multiply CSysVector by the preconditioner. | |
| void | BuildLU_SGSPreconditioner () |
| Build the LU-SGS preconditioner. | |
| void | ComputeLU_SGSPreconditioner (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Multiply CSysVector by the preconditioner. | |
| void | BuildLineletPreconditioner (const CGeometry *geometry, const CConfig *config) |
| Build the Linelet preconditioner. | |
| void | ComputeLineletPreconditioner (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Multiply CSysVector by the preconditioner. | |
| void | ComputeResidual (const CSysVector< ScalarType > &sol, const CSysVector< ScalarType > &f, CSysVector< ScalarType > &res) const |
| Compute the linear residual. | |
| void | BuildPastixPreconditioner (CGeometry *geometry, const CConfig *config, unsigned short kind_fact) |
| Factorize matrix using PaStiX. | |
| void | ComputePastixPreconditioner (const CSysVector< ScalarType > &vec, CSysVector< ScalarType > &prod, CGeometry *geometry, const CConfig *config) const |
| Apply the PaStiX factorization to CSysVec. | |
Friends | |
| struct | CSysMatrixComms |
Main class for defining block-compressed-row-storage sparse matrices.
| CSysMatrix< ScalarType >::CSysMatrix | ( | ) |
Constructor of the class.
| CSysMatrix< ScalarType >::~CSysMatrix | ( | ) |
Destructor of the class.
|
inline |
Add a scaled block (in flat format) to the sparse matrix (see SetBlock).
| [in] | block_i | - Row index. |
| [in] | block_j | - Column index. |
| [in] | val_block | - Block to set to A(i, j). |
| [in] | alpha | - Scale factor. |
|
inline |
Non overwrite version of SetBlock2Diag, also with scaling.
|
inline |
Adds the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure.
| [in] | block_i | - Diagonal index. |
| [in] | val_matrix | - Value to add to the diagonal elements of A(i, i). |
|
inline |
Adds the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure.
| [in] | block_i | - Diagonal index. |
| [in] | iVar | - Variable index. |
| [in] | val | - Value to add to the diagonal elements of A(i, i). |
| void CSysMatrix< ScalarType >::BuildILUPreconditioner | ( | ) |
Build the ILU preconditioner.
| void CSysMatrix< ScalarType >::BuildJacobiPreconditioner | ( | ) |
Build the Jacobi preconditioner.
| void CSysMatrix< ScalarType >::BuildLineletPreconditioner | ( | const CGeometry * | geometry, |
| const CConfig * | config | ||
| ) |
Build the Linelet preconditioner.
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| void CSysMatrix< ScalarType >::BuildLU_SGSPreconditioner | ( | ) |
Build the LU-SGS preconditioner.
| void CSysMatrix< ScalarType >::BuildPastixPreconditioner | ( | CGeometry * | geometry, |
| const CConfig * | config, | ||
| unsigned short | kind_fact | ||
| ) |
Factorize matrix using PaStiX.
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| [in] | kind_fact | - Type of factorization. |
| void CSysMatrix< ScalarType >::ComputeILUPreconditioner | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Multiply CSysVector by the preconditioner.
| [in] | vec | - CSysVector to be multiplied by the preconditioner. |
| [out] | prod | - Result of the product A*vec. |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| void CSysMatrix< ScalarType >::ComputeJacobiPreconditioner | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Multiply CSysVector by the preconditioner.
| [in] | vec | - CSysVector to be multiplied by the preconditioner. |
| [out] | prod | - Result of the product A*vec. |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| void CSysMatrix< ScalarType >::ComputeLineletPreconditioner | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Multiply CSysVector by the preconditioner.
| [in] | vec | - CSysVector to be multiplied by the preconditioner. |
| [out] | prod | - Result of the product A*vec. |
| void CSysMatrix< ScalarType >::ComputeLU_SGSPreconditioner | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Multiply CSysVector by the preconditioner.
| [in] | vec | - CSysVector to be multiplied by the preconditioner. |
| [out] | prod | - Result of the product A*vec. |
| void CSysMatrix< ScalarType >::ComputePastixPreconditioner | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Apply the PaStiX factorization to CSysVec.
| [in] | vec | - CSysVector to be multiplied by the preconditioner. |
| [out] | prod | - Result of the product M*vec. |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| void CSysMatrix< ScalarType >::ComputeResidual | ( | const CSysVector< ScalarType > & | sol, |
| const CSysVector< ScalarType > & | f, | ||
| CSysVector< ScalarType > & | res | ||
| ) | const |
Compute the linear residual.
| [in] | sol | - Solution (x). |
| [in] | f | - Right hand side (b). |
| [out] | res | - Residual (Ax-b). |
| void CSysMatrix< ScalarType >::DeleteValsRowi | ( | unsigned long | block_i, |
| unsigned long | row | ||
| ) |
Deletes the values of a row of the sparse matrix.
| [in] | block_i | - Index of the block. |
| [in] | row | - Row within the block. |
| void CSysMatrix< ScalarType >::EnforceSolutionAtNode | ( | unsigned long | node_i, |
| const OtherType * | x_i, | ||
| CSysVector< OtherType > & | b | ||
| ) |
Modifies this matrix (A) and a rhs vector (b) such that (A^-1 * b)_i = x_i.
| [in] | node_i | - Index of the node for which to enforce the solution of all DOF's. |
| [in] | x_i | - Values to enforce (nVar sized). |
| [in,out] | b | - The rhs vector (b := b - A_{*,i} * x_i; b_i = x_i). |
| void CSysMatrix< ScalarType >::EnforceZeroProjection | ( | unsigned long | node_i, |
| const OtherType * | n, | ||
| CSysVector< OtherType > & | b | ||
| ) |
Similar to EnforceSolutionAtNode, but for 0 projection in a given direction.
|
inline |
Get a pointer to the start of block "ij", non-const version.
|
inline |
Get a pointer to the start of block "ij".
| [in] | block_i | - Row index. |
| [in] | block_j | - Column index. |
|
inline |
Returns the 4 blocks ii, ij, ji, jj used by "UpdateBlocks".
| [in] | edge | - Index of edge that connects iPoint and jPoint. |
| [in] | iPoint | - Row to which we add the blocks. |
| [in] | jPoint | - Row from which we subtract the blocks. |
| [out] | bii,bij,bji,bjj | - Blocks of the matrix. |
|
inline |
|
inline |
Read-only view of block (block_i, block_j). In Q_LU_SGS mode values are decoded on access inside CBlockView::operator()(i,j); no temporary copy is made.
| void CSysMatrix< ScalarType >::HtDTransfer | ( | bool | trigger = true | ) | const |
Performs the memory copy from host to device.
| [in] | trigger | - boolean value that decides whether to conduct the transfer or not. True by default. |
| void CSysMatrix< ScalarType >::Initialize | ( | unsigned long | npoint, |
| unsigned long | npointdomain, | ||
| unsigned short | nvar, | ||
| unsigned short | neqn, | ||
| bool | EdgeConnect, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config, | ||
| bool | needTranspPtr = false, |
||
| bool | allow_quant = false, |
||
| std::optional< unsigned short > | override_prec = std::nullopt |
||
| ) |
Initializes the sparse matrix.
| [in] | npoint | - Number of points including halos. |
| [in] | npointdomain | - Number of points excluding halos. |
| [in] | nvar | - Number of variables (and rows of the blocks). |
| [in] | neqn | - Number of equations (and columns of the blocks). |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| [in] | needTranspPtr | - If the L/U transpose maps should be built, used for "SetDiagonalAsColumnSum". |
| [in] | allow_quant | - Quantization is only possible with solvers that "set and forget" the off-diagonal blocks of the matrix. Solvers that perform multiple updates would lose too much information, so that pattern is not supported with quantization (the code will hit null pointers). It is up to the solver to declare whether it will "set and forget". |
| [in] | override_prec | - Decide if, and with what argument to override the preconditioner. |
| void CSysMatrix< ScalarType >::MatrixMatrixAddition | ( | ScalarType | alpha, |
| const CSysMatrix< ScalarType > & | B | ||
| ) |
Add a scaled sparse matrix to "this" (axpy-type operation, A = A+alpha*B).
| [in] | alpha | - The scaling constant. |
| [in] | B | - Matrix being. |
| void CSysMatrix< ScalarType >::MatrixVectorProduct | ( | const CSysVector< ScalarType > & | vec, |
| CSysVector< ScalarType > & | prod, | ||
| CGeometry * | geometry, | ||
| const CConfig * | config | ||
| ) | const |
Performs the product of a sparse matrix by a CSysVector.
| [in] | vec | - CSysVector to be multiplied by the sparse matrix A. |
| [in] | geometry | - Geometrical definition of the problem. |
| [in] | config | - Definition of the particular problem. |
| [out] | prod | - Result of the product. |
| void CSysMatrix< ScalarType >::QuantizeDiagonalBlocks | ( | ) |
Compresses off-diagonal blocks into quantized form for use with USE_QUANTIZATION.
|
inline |
|
inline |
|
inline |
Set the value of a scaled block in the sparse matrix.
| [in] | block_i | - Row index. |
| [in] | block_j | - Column index. |
| [in] | val_block | - Block to set to A(i, j). |
| [in] | alpha | - Scale factor. |
|
inline |
Sets the specified block to the (i, i) subblock of the sparse matrix. Scales the input block by factor alpha. If the Overwrite parameter is false we update instead (bii += alpha*b).
| [in] | block_i | - Diagonal index. |
| [in] | val_block | - Block to add to the diagonal of the matrix. |
| [in] | alpha | - Scale factor. |
|
inline |
SIMD version, does the update for multiple edges.
|
inline |
SIMD version, does the update for multiple edges and points.
|
inline |
Sets 2 blocks ij and ji (add to i* sub from j*) associated with one edge of an FVM-type sparse pattern.
| [in] | edge | - Index of edge that connects iPoint and jPoint. |
| [in] | block_i | - Subs from ji. |
| [in] | block_j | - Adds to ij. |
| [in] | scale | - Scale blocks during update (axpy type op). |
|
inline |
Set the four blocks of an edge, for fluxes whose i and j contributions are independent.
| void CSysMatrix< ScalarType >::SetDiagonalAsColumnSum | ( | ) |
Sets the diagonal entries of the matrix as the sum of the blocks in the corresponding column.
|
inline |
Set the off-diagonal blocks of an edge, the diagonal being assembled elsewhere.
|
inline |
Sets the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure.
| [in] | block_i | - Diagonal index. |
| [in] | val_matrix | - Value to add to the diagonal elements of A(i, i). |
| void CSysMatrix< ScalarType >::SetValDiagonalZero | ( | ) |
Sets to zero all the block diagonal entries of the sparse matrix.
| void CSysMatrix< ScalarType >::SetValZero | ( | ) |
Sets to zero all the entries of the sparse matrix.
|
inline |
Subtracts the specified block to the sparse matrix (see AddBlock).
| [in] | block_i | - Row index. |
| [in] | block_j | - Column index. |
| [in] | val_block | - Block to subtract to A(i, j). |
|
inline |
Short-hand to AddBlock2Diag with alpha = -1, i.e. subtracts from the current diagonal.
| void CSysMatrix< ScalarType >::TransposeInPlace | ( | ) |
Transposes the matrix, any preconditioner that was computed may be invalid.
|
inline |
Short-hand for the "additive overwrite" version of SetBlocks.
|
inline |
Update 4 blocks ii, ij, ji, jj (add to i* sub from j*).
| [in] | edge | - Index of edge that connects iPoint and jPoint. |
| [in] | iPoint | - Row to which we add the blocks. |
| [in] | jPoint | - Row from which we subtract the blocks. |
| [in] | block_i | - Adds to ii, subs from ji. |
| [in] | block_j | - Adds to ij, subs from jj. |
| [in] | scale | - Scale blocks during update (axpy type op). |
|
inline |
Short-hand for the "subtractive" version (sub from i* add to j*) of SetBlocks.
|
inline |
Short-hand for the "subtractive" version (sub from i* add to j*) of UpdateBlocks.
|
friend |