class
#include <src/LinearSolver/CSR.hpp>
CSR Compressed sparse row (CSR) storage for a sparse matrix.
Constructors, destructors, conversion operators
Public functions
- auto operator()(std::size_t row, std::size_t col, std::size_t pos = 0) const -> const real&
- Return const reference to sparse matrix entry at a position.
- auto operator()(std::size_t row, std::size_t col, std::size_t pos = 0) -> real&
-
void dirichlet(std::size_t i,
tk::
real val, std::vector<tk:: real>& b, const std::vector<std::size_t>& gid = {}, const std::unordered_map<int, std::unordered_set<std::size_t>>& nodecommap = {}, std::size_t pos = 0) - Set Dirichlet boundary condition at a node.
- void mult(const std::vector<real>& x, std::vector<real>& r) const
- Multiply CSR matrix with vector from the right: r = A * x.
- void zero()
- Zero matrix values.
- auto rsize() const -> std::size_t
- Access real size of matrix.
- auto Ncomp() const -> std::size_t
- Access the number of scalar components per non-zero matrix entry.
- auto write_stored(std::ostream& os) const -> std::ostream&
- Write out CSR as stored.
- auto write_structure(std::ostream& os) const -> std::ostream&
- Write out CSR nonzero structure.
- auto write_contribute(std::ostream& os) const -> std::ostream&
- Write out CSR contribute structure.
- auto write_matrix(std::ostream& os) const -> std::ostream&
- Write out CSR as a real matrix.
- auto write_matlab(std::ostream& os) const -> std::ostream&
- Write out CSR in Matlab/Octave format.
Pack/unpack (Charm++ serialization) routines
Function documentation
tk:: CSR:: CSR(std::size_t nc,
const std::pair<std::vector<std::size_t>, std::vector<std::size_t>>& psup) explicit
Constructor: Create a CSR symmetric matrix with ncomp scalar components, storing only the upper triangular part.
Parameters | |
---|---|
nc in | Number of scalar components (degrees of freedom) |
psup in | Points surrounding points of mesh graph, see tk:: |
const real& tk:: CSR:: operator()(std::size_t row,
std::size_t col,
std::size_t pos = 0) const
Return const reference to sparse matrix entry at a position.
Parameters | |
---|---|
row in | Block row |
col in | Block column |
pos in | Position in block |
Returns | Const reference to matrix entry at position specified |
real& tk:: CSR:: operator()(std::size_t row,
std::size_t col,
std::size_t pos = 0)
Return non-const reference to sparse matrix entry at a position
void tk:: CSR:: dirichlet(std::size_t i,
tk:: real val,
std::vector<tk:: real>& b,
const std::vector<std::size_t>& gid = {},
const std::unordered_map<int, std::unordered_set<std::size_t>>& nodecommap = {},
std::size_t pos = 0)
Set Dirichlet boundary condition at a node.
Parameters | |
---|---|
i in | Local id at which to set Dirichlet BC |
val in | Value of Dirichlet BC |
b in/out | RHS to modify as a result of setting the Dirichlet BC |
gid in | Local->global node id map |
nodecommap in | Node communication map with global node ids |
pos in | Position in block |
In parallel there can be multiple contributions to a single node on the mesh, and correspondingly, a single matrix row can be partially represented on multiple partitions. Setting a Dirichlet BC entails zeroing out the row of the matrix and putting 1/N into the diagonal entry, where N is the number of partitions that contribute to the mesh node (matrix row). As a result, when the matrix participates in a matrix-vector product, where the partial contributions across all partitions are aggregated, the diagonal will contain 1 after the sum across partitions.
std::ostream& tk:: CSR:: write_stored(std::ostream& os) const
Write out CSR as stored.
Parameters | |
---|---|
os in/out | Output stream to write to |
Returns | Updated output stream |
std::ostream& tk:: CSR:: write_structure(std::ostream& os) const
Write out CSR nonzero structure.
Parameters | |
---|---|
os in/out | Output stream to write to |
Returns | Updated output stream |
std::ostream& tk:: CSR:: write_matrix(std::ostream& os) const
Write out CSR as a real matrix.
Parameters | |
---|---|
os in/out | Output stream to write to |
Returns | Updated output stream |
std::ostream& tk:: CSR:: write_matlab(std::ostream& os) const
Write out CSR in Matlab/Octave format.
Parameters | |
---|---|
os in/out | Output stream to write to |
Returns | Updated output stream |
void tk:: CSR:: pup(PUP::er& p)
Pack/Unpack serialize member function.
Parameters | |
---|---|
p in/out | Charm++'s PUP::er serializer object reference |