KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
An utility to multiply sparse matrix in Ublas. More...
#include <sparse_matrix_multiplication_utility.h>
Classes | |
struct | value_type |
Metafunction that returns value type of a matrix or a vector type. More... | |
Public Member Functions | |
Life Cycle | |
SparseMatrixMultiplicationUtility () | |
Default constructor. More... | |
virtual | ~SparseMatrixMultiplicationUtility ()=default |
Desctructor. More... | |
Input and output | |
std::string | Info () const |
Turn back information as a string. More... | |
void | PrintInfo (std::ostream &rOStream) const |
Print information about this object. More... | |
void | PrintData (std::ostream &rOStream) const |
Print object's data. More... | |
Static Public Member Functions | |
Operations | |
template<class AMatrix , class BMatrix , class CMatrix > | |
static void | MatrixMultiplication (const AMatrix &rA, const BMatrix &rB, CMatrix &rC) |
Matrix-matrix product C = A·B @detail This method uses a template for each matrix. More... | |
template<class AMatrix , class BMatrix , class CMatrix > | |
static void | MatrixMultiplicationSaad (const AMatrix &A, const BMatrix &B, CMatrix &C) |
The first is an OpenMP-enabled modification of classic algorithm from Saad. More... | |
template<class AMatrix , class BMatrix , class CMatrix > | |
static void | MatrixMultiplicationRMerge (const AMatrix &A, const BMatrix &B, CMatrix &C) |
Row-merge algorithm from Rupp et al. More... | |
template<class AMatrix , class BMatrix > | |
static void | MatrixAdd (AMatrix &A, const BMatrix &B, const double Factor=1.0) |
The first is a method in order to sum to sparse matrices in a efficient way. More... | |
template<class AMatrix , class BMatrix > | |
static void | TransposeMatrix (AMatrix &rA, const BMatrix &rB, const double Factor=1.0) |
This method computes of the transpose matrix of a given matrix. More... | |
template<class CMatrix , typename TSize , typename Ptr , typename IndexType , typename ValueType > | |
static void | CreateSolutionMatrix (CMatrix &C, const TSize NRows, const TSize NCols, const Ptr *CPtr, const IndexType *AuxIndex2C, const ValueType *AuxValC) |
This method is designed to create the final solution sparse matrix from the auxiliar values. More... | |
template<typename TSize , typename Col , typename TIndexType , typename ValueType > | |
static void | SortRows (const TIndexType *CPtr, const TSize NRows, const TSize NCols, Col *Columns, ValueType *Values) |
This method is designed to reorder the rows by columns. More... | |
static void | AssembleSparseMatrixByBlocks (CompressedMatrix &rMatrix, const DenseMatrix< CompressedMatrix * > &rMatricespBlocks, DenseMatrix< double > ContributionCoefficients=DenseMatrix< double >(0, 0), DenseMatrix< bool > TransposeBlocks=DenseMatrix< bool >(0, 0)) |
This method assembles several sparse matrices into one large sparse matrix. More... | |
static void | ComputeNonZeroBlocks (const CompressedMatrix &rMatrix, const int CurrentRow, IndexType &rNonZeroColsAux2) |
This is a method to check the block containing nonzero values. More... | |
static void | ComputeAuxiliarValuesBlocks (const CompressedMatrix &rMatrix, IndexType *AuxIndex2, double *AuxVals, const int CurrentRow, IndexType &RowEnd, const SizeType InitialIndexColumn, const double ContributionCoefficient=1.0) |
This is a method to compute the contribution of the auxiliar blocks. More... | |
Type Definitions | |
typedef std::size_t | SizeType |
The size type. More... | |
typedef std::size_t | IndexType |
The index type. More... | |
typedef std::ptrdiff_t | SignedIndexType |
The signed index type. More... | |
typedef DenseVector< IndexType > | IndexVectorType |
A vector of indexes. More... | |
typedef DenseVector< SignedIndexType > | SignedIndexVectorType |
A vector of indexes (signed) More... | |
KRATOS_CLASS_POINTER_DEFINITION (SparseMatrixMultiplicationUtility) | |
Pointer definition of TreeContactSearch. More... | |
An utility to multiply sparse matrix in Ublas.
Taken and adapted for ublas from external_libraries/amgcl/detail/spgemm.hpp by Denis Demidov denni s.de midov @gma il.co m
typedef std::size_t Kratos::SparseMatrixMultiplicationUtility::IndexType |
The index type.
A vector of indexes.
typedef std::ptrdiff_t Kratos::SparseMatrixMultiplicationUtility::SignedIndexType |
The signed index type.
typedef DenseVector<SignedIndexType> Kratos::SparseMatrixMultiplicationUtility::SignedIndexVectorType |
A vector of indexes (signed)
typedef std::size_t Kratos::SparseMatrixMultiplicationUtility::SizeType |
The size type.
|
inline |
Default constructor.
|
virtualdefault |
Desctructor.
|
inlinestatic |
This method assembles several sparse matrices into one large sparse matrix.
rMatricespBlocks | The pointers to the matrices we are interested in assemble |
ContributionCoefficients | The matrix containing the coefficients to be considered (copy, so we don't need to provide it) |
TransposeBlocks | The matrix containing the flags telling us to transpose the blocks (copy, so we don't need to provide it) |
|
inlinestatic |
This is a method to compute the contribution of the auxiliar blocks.
AuxK | The auxiliar block |
AuxIndex2 | The indexes of the non zero columns |
AuxVals | The values of the final matrix |
CurrentRow | The current row computed |
RowEnd | The last column computed |
InitialIndexColumn | The initial column index of the auxiliar block in the final matrix |
|
inlinestatic |
This is a method to check the block containing nonzero values.
rMatrix | The auxiliar block |
CurrentRow | The current row computed |
rNonZeroColsAux2 | The nonzero rows array |
|
inlinestatic |
This method is designed to create the final solution sparse matrix from the auxiliar values.
C | The matrix solution |
NRows | The number of rows of the matrix |
NCols | The number of columns of the matrix |
CPtr | The indexes taht indicate the number of nonzero values in each column |
AuxIndex2C | The indexes of the nonzero columns |
AuxValC | The C array containing the values of the sparse matrix |
|
inline |
Turn back information as a string.
Kratos::SparseMatrixMultiplicationUtility::KRATOS_CLASS_POINTER_DEFINITION | ( | SparseMatrixMultiplicationUtility | ) |
Pointer definition of TreeContactSearch.
|
inlinestatic |
The first is a method in order to sum to sparse matrices in a efficient way.
A | The resulting matrix |
B | The second matrix to sum |
|
inlinestatic |
Matrix-matrix product C = A·B @detail This method uses a template for each matrix.
rA | The first matrix |
rB | The second matrix |
rC | The resulting matrix |
|
inlinestatic |
Row-merge algorithm from Rupp et al.
The algorithm requires less memory and shows much better scalability than classic one. It is used when number of OpenMP cores is more than 4.
A | The first matrix to multiply |
B | The second matrix to multiply |
C | The resulting matrix |
|
inlinestatic |
The first is an OpenMP-enabled modification of classic algorithm from Saad.
It is used whenever number of OpenMP cores is 4 or less. Saad, Yousef. Iterative methods for sparse linear systems. Siam, 2003.
A | The first matrix to multiply |
B | The second matrix to multiply |
C | The resulting matrix |
|
inline |
Print object's data.
|
inline |
Print information about this object.
|
inlinestatic |
This method is designed to reorder the rows by columns.
NRows | The number of rows of the matrix |
NCols | The number of columns of the matrix |
CPtr | The indexes taht indicate the number of nonzero values in each column |
Columns | The columns of the problem |
Values | The values (to be ordered with the rows) |
|
inlinestatic |
This method computes of the transpose matrix of a given matrix.
rA | The resulting matrix |
rB | The second matrix to transpose |